added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / CSAzureWebRoleIdentity / WebRole_RP / Scripts / jquery-1.4.1-vsdoc.js
blob681241d10c8cfc38a026719720e68034b370dae6
1 /*
2 * This file has been commented to support Visual Studio Intellisense.
3 * You should not use this file at runtime inside the browser--it is only
4 * intended to be used only for design-time IntelliSense. Please use the
5 * standard jQuery library for all production use.
7 * Comment version: 1.4.1a
8 */
10 /*!
11 * jQuery JavaScript Library v1.4.1
12 * http://jquery.com/
14 * Distributed in whole under the terms of the MIT
16 * Copyright 2010, John Resig
18 * Permission is hereby granted, free of charge, to any person obtaining
19 * a copy of this software and associated documentation files (the
20 * "Software"), to deal in the Software without restriction, including
21 * without limitation the rights to use, copy, modify, merge, publish,
22 * distribute, sublicense, and/or sell copies of the Software, and to
23 * permit persons to whom the Software is furnished to do so, subject to
24 * the following conditions:
26 * The above copyright notice and this permission notice shall be
27 * included in all copies or substantial portions of the Software.
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 * Includes Sizzle.js
38 * http://sizzlejs.com/
39 * Copyright 2010, The Dojo Foundation
40 * Released under the MIT, BSD, and GPL Licenses.
42 * Date: Mon Jan 25 19:43:33 2010 -0500
45 (function( window, undefined ) {
47 // Define a local copy of jQuery
48 var jQuery = function( selector, context ) {
49 /// <summary>
50 /// 1: $(expression, context) - This function accepts a string containing a CSS selector which is then used to match a set of elements.
51 /// 2: $(html) - Create DOM elements on-the-fly from the provided String of raw HTML.
52 /// 3: $(elements) - Wrap jQuery functionality around a single or multiple DOM Element(s).
53 /// 4: $(callback) - A shorthand for $(document).ready().
54 /// 5: $() - As of jQuery 1.4, if you pass no arguments in to the jQuery() method, an empty jQuery set will be returned.
55 /// </summary>
56 /// <param name="selector" type="String">
57 /// 1: expression - An expression to search with.
58 /// 2: html - A string of HTML to create on the fly.
59 /// 3: elements - DOM element(s) to be encapsulated by a jQuery object.
60 /// 4: callback - The function to execute when the DOM is ready.
61 /// </param>
62 /// <param name="context" type="jQuery">
63 /// 1: context - A DOM Element, Document or jQuery to use as context.
64 /// </param>
65 /// <returns type="jQuery" />
67 // The jQuery object is actually just the init constructor 'enhanced'
68 return new jQuery.fn.init( selector, context );
71 // Map over jQuery in case of overwrite
72 _jQuery = window.jQuery,
74 // Map over the $ in case of overwrite
75 _$ = window.$,
77 // Use the correct document accordingly with window argument (sandbox)
78 document = window.document,
80 // A central reference to the root jQuery(document)
81 rootjQuery,
83 // A simple way to check for HTML strings or ID strings
84 // (both of which we optimize for)
85 quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
87 // Is it a simple selector
88 isSimple = /^.[^:#\[\.,]*$/,
90 // Check if a string has a non-whitespace character in it
91 rnotwhite = /\S/,
93 // Used for trimming whitespace
94 rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
96 // Match a standalone tag
97 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
99 // Keep a UserAgent string for use with jQuery.browser
100 userAgent = navigator.userAgent,
102 // For matching the engine and version of the browser
103 browserMatch,
105 // Has the ready events already been bound?
106 readyBound = false,
108 // The functions to execute on DOM ready
109 readyList = [],
111 // The ready event handler
112 DOMContentLoaded,
114 // Save a reference to some core methods
115 toString = Object.prototype.toString,
116 hasOwnProperty = Object.prototype.hasOwnProperty,
117 push = Array.prototype.push,
118 slice = Array.prototype.slice,
119 indexOf = Array.prototype.indexOf;
121 jQuery.fn = jQuery.prototype = {
122 init: function( selector, context ) {
124 var match, elem, ret, doc;
126 // Handle $(""), $(null), or $(undefined)
127 if ( !selector ) {
128 return this;
131 // Handle $(DOMElement)
132 if ( selector.nodeType ) {
133 this.context = this[0] = selector;
134 this.length = 1;
135 return this;
138 // Handle HTML strings
139 if ( typeof selector === "string" ) {
140 // Are we dealing with HTML string or an ID?
141 match = quickExpr.exec( selector );
143 // Verify a match, and that no context was specified for #id
144 if ( match && (match[1] || !context) ) {
146 // HANDLE: $(html) -> $(array)
147 if ( match[1] ) {
148 doc = (context ? context.ownerDocument || context : document);
150 // If a single string is passed in and it's a single tag
151 // just do a createElement and skip the rest
152 ret = rsingleTag.exec( selector );
154 if ( ret ) {
155 if ( jQuery.isPlainObject( context ) ) {
156 selector = [ document.createElement( ret[1] ) ];
157 jQuery.fn.attr.call( selector, context, true );
159 } else {
160 selector = [ doc.createElement( ret[1] ) ];
163 } else {
164 ret = buildFragment( [ match[1] ], [ doc ] );
165 selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
168 // HANDLE: $("#id")
169 } else {
170 elem = document.getElementById( match[2] );
172 if ( elem ) {
173 // Handle the case where IE and Opera return items
174 // by name instead of ID
175 if ( elem.id !== match[2] ) {
176 return rootjQuery.find( selector );
179 // Otherwise, we inject the element directly into the jQuery object
180 this.length = 1;
181 this[0] = elem;
184 this.context = document;
185 this.selector = selector;
186 return this;
189 // HANDLE: $("TAG")
190 } else if ( !context && /^\w+$/.test( selector ) ) {
191 this.selector = selector;
192 this.context = document;
193 selector = document.getElementsByTagName( selector );
195 // HANDLE: $(expr, $(...))
196 } else if ( !context || context.jquery ) {
197 return (context || rootjQuery).find( selector );
199 // HANDLE: $(expr, context)
200 // (which is just equivalent to: $(context).find(expr)
201 } else {
202 return jQuery( context ).find( selector );
205 // HANDLE: $(function)
206 // Shortcut for document ready
207 } else if ( jQuery.isFunction( selector ) ) {
208 return rootjQuery.ready( selector );
211 if (selector.selector !== undefined) {
212 this.selector = selector.selector;
213 this.context = selector.context;
216 return jQuery.isArray( selector ) ?
217 this.setArray( selector ) :
218 jQuery.makeArray( selector, this );
221 // Start with an empty selector
222 selector: "",
224 // The current version of jQuery being used
225 jquery: "1.4.1",
227 // The default length of a jQuery object is 0
228 length: 0,
230 // The number of elements contained in the matched element set
231 size: function() {
232 /// <summary>
233 /// The number of elements currently matched.
234 /// Part of Core
235 /// </summary>
236 /// <returns type="Number" />
238 return this.length;
241 toArray: function() {
242 /// <summary>
243 /// Retrieve all the DOM elements contained in the jQuery set, as an array.
244 /// </summary>
245 /// <returns type="Array" />
246 return slice.call( this, 0 );
249 // Get the Nth element in the matched element set OR
250 // Get the whole matched element set as a clean array
251 get: function( num ) {
252 /// <summary>
253 /// Access a single matched element. num is used to access the
254 /// Nth element matched.
255 /// Part of Core
256 /// </summary>
257 /// <returns type="Element" />
258 /// <param name="num" type="Number">
259 /// Access the element in the Nth position.
260 /// </param>
262 return num == null ?
264 // Return a 'clean' array
265 this.toArray() :
267 // Return just the object
268 ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
271 // Take an array of elements and push it onto the stack
272 // (returning the new matched element set)
273 pushStack: function( elems, name, selector ) {
274 /// <summary>
275 /// Set the jQuery object to an array of elements, while maintaining
276 /// the stack.
277 /// Part of Core
278 /// </summary>
279 /// <returns type="jQuery" />
280 /// <param name="elems" type="Elements">
281 /// An array of elements
282 /// </param>
284 // Build a new jQuery matched element set
285 var ret = jQuery( elems || null );
287 // Add the old object onto the stack (as a reference)
288 ret.prevObject = this;
290 ret.context = this.context;
292 if ( name === "find" ) {
293 ret.selector = this.selector + (this.selector ? " " : "") + selector;
294 } else if ( name ) {
295 ret.selector = this.selector + "." + name + "(" + selector + ")";
298 // Return the newly-formed element set
299 return ret;
302 // Force the current matched set of elements to become
303 // the specified array of elements (destroying the stack in the process)
304 // You should use pushStack() in order to do this, but maintain the stack
305 setArray: function( elems ) {
306 /// <summary>
307 /// Set the jQuery object to an array of elements. This operation is
308 /// completely destructive - be sure to use .pushStack() if you wish to maintain
309 /// the jQuery stack.
310 /// Part of Core
311 /// </summary>
312 /// <returns type="jQuery" />
313 /// <param name="elems" type="Elements">
314 /// An array of elements
315 /// </param>
317 // Resetting the length to 0, then using the native Array push
318 // is a super-fast way to populate an object with array-like properties
319 this.length = 0;
320 push.apply( this, elems );
322 return this;
325 // Execute a callback for every element in the matched set.
326 // (You can seed the arguments with an array of args, but this is
327 // only used internally.)
328 each: function( callback, args ) {
329 /// <summary>
330 /// Execute a function within the context of every matched element.
331 /// This means that every time the passed-in function is executed
332 /// (which is once for every element matched) the 'this' keyword
333 /// points to the specific element.
334 /// Additionally, the function, when executed, is passed a single
335 /// argument representing the position of the element in the matched
336 /// set.
337 /// Part of Core
338 /// </summary>
339 /// <returns type="jQuery" />
340 /// <param name="callback" type="Function">
341 /// A function to execute
342 /// </param>
344 return jQuery.each( this, callback, args );
347 ready: function( fn ) {
348 /// <summary>
349 /// Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.
350 /// </summary>
351 /// <param name="fn" type="Function">The function to be executed when the DOM is ready.</param>
353 // Attach the listeners
354 jQuery.bindReady();
356 // If the DOM is already ready
357 if ( jQuery.isReady ) {
358 // Execute the function immediately
359 fn.call( document, jQuery );
361 // Otherwise, remember the function for later
362 } else if ( readyList ) {
363 // Add the function to the wait list
364 readyList.push( fn );
367 return this;
370 eq: function( i ) {
371 /// <summary>
372 /// Reduce the set of matched elements to a single element.
373 /// The position of the element in the set of matched elements
374 /// starts at 0 and goes to length - 1.
375 /// Part of Core
376 /// </summary>
377 /// <returns type="jQuery" />
378 /// <param name="num" type="Number">
379 /// pos The index of the element that you wish to limit to.
380 /// </param>
382 return i === -1 ?
383 this.slice( i ) :
384 this.slice( i, +i + 1 );
387 first: function() {
388 /// <summary>
389 /// Reduce the set of matched elements to the first in the set.
390 /// </summary>
391 /// <returns type="jQuery" />
393 return this.eq( 0 );
396 last: function() {
397 /// <summary>
398 /// Reduce the set of matched elements to the final one in the set.
399 /// </summary>
400 /// <returns type="jQuery" />
402 return this.eq( -1 );
405 slice: function() {
406 /// <summary>
407 /// Selects a subset of the matched elements. Behaves exactly like the built-in Array slice method.
408 /// </summary>
409 /// <param name="start" type="Number" integer="true">Where to start the subset (0-based).</param>
410 /// <param name="end" optional="true" type="Number" integer="true">Where to end the subset (not including the end element itself).
411 /// If omitted, ends at the end of the selection</param>
412 /// <returns type="jQuery">The sliced elements</returns>
414 return this.pushStack( slice.apply( this, arguments ),
415 "slice", slice.call(arguments).join(",") );
418 map: function( callback ) {
419 /// <summary>
420 /// This member is internal.
421 /// </summary>
422 /// <private />
423 /// <returns type="jQuery" />
425 return this.pushStack( jQuery.map(this, function( elem, i ) {
426 return callback.call( elem, i, elem );
427 }));
430 end: function() {
431 /// <summary>
432 /// End the most recent 'destructive' operation, reverting the list of matched elements
433 /// back to its previous state. After an end operation, the list of matched elements will
434 /// revert to the last state of matched elements.
435 /// If there was no destructive operation before, an empty set is returned.
436 /// Part of DOM/Traversing
437 /// </summary>
438 /// <returns type="jQuery" />
440 return this.prevObject || jQuery(null);
443 // For internal use only.
444 // Behaves like an Array's method, not like a jQuery method.
445 push: push,
446 sort: [].sort,
447 splice: [].splice
450 // Give the init function the jQuery prototype for later instantiation
451 jQuery.fn.init.prototype = jQuery.fn;
453 jQuery.extend = jQuery.fn.extend = function() {
454 /// <summary>
455 /// Extend one object with one or more others, returning the original,
456 /// modified, object. This is a great utility for simple inheritance.
457 /// jQuery.extend(settings, options);
458 /// var settings = jQuery.extend({}, defaults, options);
459 /// Part of JavaScript
460 /// </summary>
461 /// <param name="target" type="Object">
462 /// The object to extend
463 /// </param>
464 /// <param name="prop1" type="Object">
465 /// The object that will be merged into the first.
466 /// </param>
467 /// <param name="propN" type="Object" optional="true" parameterArray="true">
468 /// (optional) More objects to merge into the first
469 /// </param>
470 /// <returns type="Object" />
472 // copy reference to target object
473 var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
475 // Handle a deep copy situation
476 if ( typeof target === "boolean" ) {
477 deep = target;
478 target = arguments[1] || {};
479 // skip the boolean and the target
480 i = 2;
483 // Handle case when target is a string or something (possible in deep copy)
484 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
485 target = {};
488 // extend jQuery itself if only one argument is passed
489 if ( length === i ) {
490 target = this;
491 --i;
494 for ( ; i < length; i++ ) {
495 // Only deal with non-null/undefined values
496 if ( (options = arguments[ i ]) != null ) {
497 // Extend the base object
498 for ( name in options ) {
499 src = target[ name ];
500 copy = options[ name ];
502 // Prevent never-ending loop
503 if ( target === copy ) {
504 continue;
507 // Recurse if we're merging object literal values or arrays
508 if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
509 var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
510 : jQuery.isArray(copy) ? [] : {};
512 // Never move original objects, clone them
513 target[ name ] = jQuery.extend( deep, clone, copy );
515 // Don't bring in undefined values
516 } else if ( copy !== undefined ) {
517 target[ name ] = copy;
523 // Return the modified object
524 return target;
527 jQuery.extend({
528 noConflict: function( deep ) {
529 /// <summary>
530 /// Run this function to give control of the $ variable back
531 /// to whichever library first implemented it. This helps to make
532 /// sure that jQuery doesn't conflict with the $ object
533 /// of other libraries.
534 /// By using this function, you will only be able to access jQuery
535 /// using the 'jQuery' variable. For example, where you used to do
536 /// $(&quot;div p&quot;), you now must do jQuery(&quot;div p&quot;).
537 /// Part of Core
538 /// </summary>
539 /// <returns type="undefined" />
541 window.$ = _$;
543 if ( deep ) {
544 window.jQuery = _jQuery;
547 return jQuery;
550 // Is the DOM ready to be used? Set to true once it occurs.
551 isReady: false,
553 // Handle when the DOM is ready
554 ready: function() {
555 /// <summary>
556 /// This method is internal.
557 /// </summary>
558 /// <private />
560 // Make sure that the DOM is not already loaded
561 if ( !jQuery.isReady ) {
562 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
563 if ( !document.body ) {
564 return setTimeout( jQuery.ready, 13 );
567 // Remember that the DOM is ready
568 jQuery.isReady = true;
570 // If there are functions bound, to execute
571 if ( readyList ) {
572 // Execute all of them
573 var fn, i = 0;
574 while ( (fn = readyList[ i++ ]) ) {
575 fn.call( document, jQuery );
578 // Reset the list of functions
579 readyList = null;
582 // Trigger any bound ready events
583 if ( jQuery.fn.triggerHandler ) {
584 jQuery( document ).triggerHandler( "ready" );
589 bindReady: function() {
590 if ( readyBound ) {
591 return;
594 readyBound = true;
596 // Catch cases where $(document).ready() is called after the
597 // browser event has already occurred.
598 if ( document.readyState === "complete" ) {
599 return jQuery.ready();
602 // Mozilla, Opera and webkit nightlies currently support this event
603 if ( document.addEventListener ) {
604 // Use the handy event callback
605 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
607 // A fallback to window.onload, that will always work
608 window.addEventListener( "load", jQuery.ready, false );
610 // If IE event model is used
611 } else if ( document.attachEvent ) {
612 // ensure firing before onload,
613 // maybe late but safe also for iframes
614 document.attachEvent("onreadystatechange", DOMContentLoaded);
616 // A fallback to window.onload, that will always work
617 window.attachEvent( "onload", jQuery.ready );
619 // If IE and not a frame
620 // continually check to see if the document is ready
621 var toplevel = false;
623 try {
624 toplevel = window.frameElement == null;
625 } catch(e) {}
627 if ( document.documentElement.doScroll && toplevel ) {
628 doScrollCheck();
633 // See test/unit/core.js for details concerning isFunction.
634 // Since version 1.3, DOM methods and functions like alert
635 // aren't supported. They return false on IE (#2968).
636 isFunction: function( obj ) {
637 /// <summary>
638 /// Determines if the parameter passed is a function.
639 /// </summary>
640 /// <param name="obj" type="Object">The object to check</param>
641 /// <returns type="Boolean">True if the parameter is a function; otherwise false.</returns>
643 return toString.call(obj) === "[object Function]";
646 isArray: function( obj ) {
647 /// <summary>
648 /// Determine if the parameter passed is an array.
649 /// </summary>
650 /// <param name="obj" type="Object">Object to test whether or not it is an array.</param>
651 /// <returns type="Boolean">True if the parameter is a function; otherwise false.</returns>
653 return toString.call(obj) === "[object Array]";
656 isPlainObject: function( obj ) {
657 /// <summary>
658 /// Check to see if an object is a plain object (created using "{}" or "new Object").
659 /// </summary>
660 /// <param name="obj" type="Object">
661 /// The object that will be checked to see if it's a plain object.
662 /// </param>
663 /// <returns type="Boolean" />
665 // Must be an Object.
666 // Because of IE, we also have to check the presence of the constructor property.
667 // Make sure that DOM nodes and window objects don't pass through, as well
668 if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
669 return false;
672 // Not own constructor property must be Object
673 if ( obj.constructor
674 && !hasOwnProperty.call(obj, "constructor")
675 && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
676 return false;
679 // Own properties are enumerated firstly, so to speed up,
680 // if last one is own, then all properties are own.
682 var key;
683 for ( key in obj ) {}
685 return key === undefined || hasOwnProperty.call( obj, key );
688 isEmptyObject: function( obj ) {
689 /// <summary>
690 /// Check to see if an object is empty (contains no properties).
691 /// </summary>
692 /// <param name="obj" type="Object">
693 /// The object that will be checked to see if it's empty.
694 /// </param>
695 /// <returns type="Boolean" />
697 for ( var name in obj ) {
698 return false;
700 return true;
703 error: function( msg ) {
704 throw msg;
707 parseJSON: function( data ) {
708 if ( typeof data !== "string" || !data ) {
709 return null;
712 // Make sure the incoming data is actual JSON
713 // Logic borrowed from http://json.org/json2.js
714 if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
715 .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
716 .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
718 // Try to use the native JSON parser first
719 return window.JSON && window.JSON.parse ?
720 window.JSON.parse( data ) :
721 (new Function("return " + data))();
723 } else {
724 jQuery.error( "Invalid JSON: " + data );
728 noop: function() {
729 /// <summary>
730 /// An empty function.
731 /// </summary>
732 /// <returns type="Function" />
735 // Evalulates a script in a global context
736 globalEval: function( data ) {
737 /// <summary>
738 /// Internally evaluates a script in a global context.
739 /// </summary>
740 /// <private />
742 if ( data && rnotwhite.test(data) ) {
743 // Inspired by code by Andrea Giammarchi
744 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
745 var head = document.getElementsByTagName("head")[0] || document.documentElement,
746 script = document.createElement("script");
748 script.type = "text/javascript";
750 if ( jQuery.support.scriptEval ) {
751 script.appendChild( document.createTextNode( data ) );
752 } else {
753 script.text = data;
756 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
757 // This arises when a base node is used (#2709).
758 head.insertBefore( script, head.firstChild );
759 head.removeChild( script );
763 nodeName: function( elem, name ) {
764 /// <summary>
765 /// Checks whether the specified element has the specified DOM node name.
766 /// </summary>
767 /// <param name="elem" type="Element">The element to examine</param>
768 /// <param name="name" type="String">The node name to check</param>
769 /// <returns type="Boolean">True if the specified node name matches the node's DOM node name; otherwise false</returns>
771 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
774 // args is for internal usage only
775 each: function( object, callback, args ) {
776 /// <summary>
777 /// A generic iterator function, which can be used to seemlessly
778 /// iterate over both objects and arrays. This function is not the same
779 /// as $().each() - which is used to iterate, exclusively, over a jQuery
780 /// object. This function can be used to iterate over anything.
781 /// The callback has two arguments:the key (objects) or index (arrays) as first
782 /// the first, and the value as the second.
783 /// Part of JavaScript
784 /// </summary>
785 /// <param name="obj" type="Object">
786 /// The object, or array, to iterate over.
787 /// </param>
788 /// <param name="fn" type="Function">
789 /// The function that will be executed on every object.
790 /// </param>
791 /// <returns type="Object" />
793 var name, i = 0,
794 length = object.length,
795 isObj = length === undefined || jQuery.isFunction(object);
797 if ( args ) {
798 if ( isObj ) {
799 for ( name in object ) {
800 if ( callback.apply( object[ name ], args ) === false ) {
801 break;
804 } else {
805 for ( ; i < length; ) {
806 if ( callback.apply( object[ i++ ], args ) === false ) {
807 break;
812 // A special, fast, case for the most common use of each
813 } else {
814 if ( isObj ) {
815 for ( name in object ) {
816 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
817 break;
820 } else {
821 for ( var value = object[0];
822 i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
826 return object;
829 trim: function( text ) {
830 /// <summary>
831 /// Remove the whitespace from the beginning and end of a string.
832 /// Part of JavaScript
833 /// </summary>
834 /// <returns type="String" />
835 /// <param name="text" type="String">
836 /// The string to trim.
837 /// </param>
839 return (text || "").replace( rtrim, "" );
842 // results is for internal usage only
843 makeArray: function( array, results ) {
844 /// <summary>
845 /// Turns anything into a true array. This is an internal method.
846 /// </summary>
847 /// <param name="array" type="Object">Anything to turn into an actual Array</param>
848 /// <returns type="Array" />
849 /// <private />
851 var ret = results || [];
853 if ( array != null ) {
854 // The window, strings (and functions) also have 'length'
855 // The extra typeof function check is to prevent crashes
856 // in Safari 2 (See: #3039)
857 if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
858 push.call( ret, array );
859 } else {
860 jQuery.merge( ret, array );
864 return ret;
867 inArray: function( elem, array ) {
868 if ( array.indexOf ) {
869 return array.indexOf( elem );
872 for ( var i = 0, length = array.length; i < length; i++ ) {
873 if ( array[ i ] === elem ) {
874 return i;
878 return -1;
881 merge: function( first, second ) {
882 /// <summary>
883 /// Merge two arrays together, removing all duplicates.
884 /// The new array is: All the results from the first array, followed
885 /// by the unique results from the second array.
886 /// Part of JavaScript
887 /// </summary>
888 /// <returns type="Array" />
889 /// <param name="first" type="Array">
890 /// The first array to merge.
891 /// </param>
892 /// <param name="second" type="Array">
893 /// The second array to merge.
894 /// </param>
896 var i = first.length, j = 0;
898 if ( typeof second.length === "number" ) {
899 for ( var l = second.length; j < l; j++ ) {
900 first[ i++ ] = second[ j ];
902 } else {
903 while ( second[j] !== undefined ) {
904 first[ i++ ] = second[ j++ ];
908 first.length = i;
910 return first;
913 grep: function( elems, callback, inv ) {
914 /// <summary>
915 /// Filter items out of an array, by using a filter function.
916 /// The specified function will be passed two arguments: The
917 /// current array item and the index of the item in the array. The
918 /// function must return 'true' to keep the item in the array,
919 /// false to remove it.
920 /// });
921 /// Part of JavaScript
922 /// </summary>
923 /// <returns type="Array" />
924 /// <param name="elems" type="Array">
925 /// array The Array to find items in.
926 /// </param>
927 /// <param name="fn" type="Function">
928 /// The function to process each item against.
929 /// </param>
930 /// <param name="inv" type="Boolean">
931 /// Invert the selection - select the opposite of the function.
932 /// </param>
934 var ret = [];
936 // Go through the array, only saving the items
937 // that pass the validator function
938 for ( var i = 0, length = elems.length; i < length; i++ ) {
939 if ( !inv !== !callback( elems[ i ], i ) ) {
940 ret.push( elems[ i ] );
944 return ret;
947 // arg is for internal usage only
948 map: function( elems, callback, arg ) {
949 /// <summary>
950 /// Translate all items in an array to another array of items.
951 /// The translation function that is provided to this method is
952 /// called for each item in the array and is passed one argument:
953 /// The item to be translated.
954 /// The function can then return the translated value, 'null'
955 /// (to remove the item), or an array of values - which will
956 /// be flattened into the full array.
957 /// Part of JavaScript
958 /// </summary>
959 /// <returns type="Array" />
960 /// <param name="elems" type="Array">
961 /// array The Array to translate.
962 /// </param>
963 /// <param name="fn" type="Function">
964 /// The function to process each item against.
965 /// </param>
967 var ret = [], value;
969 // Go through the array, translating each of the items to their
970 // new value (or values).
971 for ( var i = 0, length = elems.length; i < length; i++ ) {
972 value = callback( elems[ i ], i, arg );
974 if ( value != null ) {
975 ret[ ret.length ] = value;
979 return ret.concat.apply( [], ret );
982 // A global GUID counter for objects
983 guid: 1,
985 proxy: function( fn, proxy, thisObject ) {
986 /// <summary>
987 /// Takes a function and returns a new one that will always have a particular scope.
988 /// </summary>
989 /// <param name="fn" type="Function">
990 /// The function whose scope will be changed.
991 /// </param>
992 /// <param name="proxy" type="Object">
993 /// The object to which the scope of the function should be set.
994 /// </param>
995 /// <returns type="Function" />
997 if ( arguments.length === 2 ) {
998 if ( typeof proxy === "string" ) {
999 thisObject = fn;
1000 fn = thisObject[ proxy ];
1001 proxy = undefined;
1003 } else if ( proxy && !jQuery.isFunction( proxy ) ) {
1004 thisObject = proxy;
1005 proxy = undefined;
1009 if ( !proxy && fn ) {
1010 proxy = function() {
1011 return fn.apply( thisObject || this, arguments );
1015 // Set the guid of unique handler to the same of original handler, so it can be removed
1016 if ( fn ) {
1017 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
1020 // So proxy can be declared as an argument
1021 return proxy;
1024 // Use of jQuery.browser is frowned upon.
1025 // More details: http://docs.jquery.com/Utilities/jQuery.browser
1026 uaMatch: function( ua ) {
1027 ua = ua.toLowerCase();
1029 var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
1030 /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
1031 /(msie) ([\w.]+)/.exec( ua ) ||
1032 !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
1035 return { browser: match[1] || "", version: match[2] || "0" };
1038 browser: {}
1041 browserMatch = jQuery.uaMatch( userAgent );
1042 if ( browserMatch.browser ) {
1043 jQuery.browser[ browserMatch.browser ] = true;
1044 jQuery.browser.version = browserMatch.version;
1047 // Deprecated, use jQuery.browser.webkit instead
1048 if ( jQuery.browser.webkit ) {
1049 jQuery.browser.safari = true;
1052 if ( indexOf ) {
1053 jQuery.inArray = function( elem, array ) {
1054 /// <summary>
1055 /// Determines the index of the first parameter in the array.
1056 /// </summary>
1057 /// <param name="elem">The value to see if it exists in the array.</param>
1058 /// <param name="array" type="Array">The array to look through for the value</param>
1059 /// <returns type="Number" integer="true">The 0-based index of the item if it was found, otherwise -1.</returns>
1061 return indexOf.call( array, elem );
1065 // All jQuery objects should point back to these
1066 rootjQuery = jQuery(document);
1068 // Cleanup functions for the document ready method
1069 if ( document.addEventListener ) {
1070 DOMContentLoaded = function() {
1071 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
1072 jQuery.ready();
1075 } else if ( document.attachEvent ) {
1076 DOMContentLoaded = function() {
1077 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
1078 if ( document.readyState === "complete" ) {
1079 document.detachEvent( "onreadystatechange", DOMContentLoaded );
1080 jQuery.ready();
1085 // The DOM ready check for Internet Explorer
1086 function doScrollCheck() {
1087 if ( jQuery.isReady ) {
1088 return;
1091 try {
1092 // If IE is used, use the trick by Diego Perini
1093 // http://javascript.nwbox.com/IEContentLoaded/
1094 document.documentElement.doScroll("left");
1095 } catch( error ) {
1096 setTimeout( doScrollCheck, 1 );
1097 return;
1100 // and execute any waiting functions
1101 jQuery.ready();
1104 function evalScript( i, elem ) {
1105 /// <summary>
1106 /// This method is internal.
1107 /// </summary>
1108 /// <private />
1110 if ( elem.src ) {
1111 jQuery.ajax({
1112 url: elem.src,
1113 async: false,
1114 dataType: "script"
1116 } else {
1117 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
1120 if ( elem.parentNode ) {
1121 elem.parentNode.removeChild( elem );
1125 // Mutifunctional method to get and set values to a collection
1126 // The value/s can be optionally by executed if its a function
1127 function access( elems, key, value, exec, fn, pass ) {
1128 var length = elems.length;
1130 // Setting many attributes
1131 if ( typeof key === "object" ) {
1132 for ( var k in key ) {
1133 access( elems, k, key[k], exec, fn, value );
1135 return elems;
1138 // Setting one attribute
1139 if ( value !== undefined ) {
1140 // Optionally, function values get executed if exec is true
1141 exec = !pass && exec && jQuery.isFunction(value);
1143 for ( var i = 0; i < length; i++ ) {
1144 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
1147 return elems;
1150 // Getting an attribute
1151 return length ? fn( elems[0], key ) : null;
1154 function now() {
1155 /// <summary>
1156 /// Gets the current date.
1157 /// </summary>
1158 /// <returns type="Date">The current date.</returns>
1160 return (new Date).getTime();
1163 // [vsdoc] The following function has been modified for IntelliSense.
1164 // [vsdoc] Stubbing support properties to "false" for IntelliSense compat.
1165 (function() {
1167 jQuery.support = {};
1169 // var root = document.documentElement,
1170 // script = document.createElement("script"),
1171 // div = document.createElement("div"),
1172 // id = "script" + now();
1174 // div.style.display = "none";
1175 // div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1177 // var all = div.getElementsByTagName("*"),
1178 // a = div.getElementsByTagName("a")[0];
1180 // // Can't get basic test support
1181 // if ( !all || !all.length || !a ) {
1182 // return;
1183 // }
1185 jQuery.support = {
1186 // IE strips leading whitespace when .innerHTML is used
1187 leadingWhitespace: false,
1189 // Make sure that tbody elements aren't automatically inserted
1190 // IE will insert them into empty tables
1191 tbody: false,
1193 // Make sure that link elements get serialized correctly by innerHTML
1194 // This requires a wrapper element in IE
1195 htmlSerialize: false,
1197 // Get the style information from getAttribute
1198 // (IE uses .cssText insted)
1199 style: false,
1201 // Make sure that URLs aren't manipulated
1202 // (IE normalizes it by default)
1203 hrefNormalized: false,
1205 // Make sure that element opacity exists
1206 // (IE uses filter instead)
1207 // Use a regex to work around a WebKit issue. See #5145
1208 opacity: false,
1210 // Verify style float existence
1211 // (IE uses styleFloat instead of cssFloat)
1212 cssFloat: false,
1214 // Make sure that if no value is specified for a checkbox
1215 // that it defaults to "on".
1216 // (WebKit defaults to "" instead)
1217 checkOn: false,
1219 // Make sure that a selected-by-default option has a working selected property.
1220 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1221 optSelected: false,
1223 // Will be defined later
1224 checkClone: false,
1225 scriptEval: false,
1226 noCloneEvent: false,
1227 boxModel: false
1230 // script.type = "text/javascript";
1231 // try {
1232 // script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
1233 // } catch(e) {}
1235 // root.insertBefore( script, root.firstChild );
1237 // // Make sure that the execution of code works by injecting a script
1238 // // tag with appendChild/createTextNode
1239 // // (IE doesn't support this, fails, and uses .text instead)
1240 // if ( window[ id ] ) {
1241 // jQuery.support.scriptEval = true;
1242 // delete window[ id ];
1243 // }
1245 // root.removeChild( script );
1247 // if ( div.attachEvent && div.fireEvent ) {
1248 // div.attachEvent("onclick", function click() {
1249 // // Cloning a node shouldn't copy over any
1250 // // bound event handlers (IE does this)
1251 // jQuery.support.noCloneEvent = false;
1252 // div.detachEvent("onclick", click);
1253 // });
1254 // div.cloneNode(true).fireEvent("onclick");
1255 // }
1257 // div = document.createElement("div");
1258 // div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
1260 // var fragment = document.createDocumentFragment();
1261 // fragment.appendChild( div.firstChild );
1263 // // WebKit doesn't clone checked state correctly in fragments
1264 // jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
1266 // // Figure out if the W3C box model works as expected
1267 // // document.body must exist before we can do this
1268 // jQuery(function() {
1269 // var div = document.createElement("div");
1270 // div.style.width = div.style.paddingLeft = "1px";
1272 // document.body.appendChild( div );
1273 // jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
1274 // document.body.removeChild( div ).style.display = 'none';
1275 // div = null;
1276 // });
1278 // // Technique from Juriy Zaytsev
1279 // // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1280 // var eventSupported = function( eventName ) {
1281 // var el = document.createElement("div");
1282 // eventName = "on" + eventName;
1284 // var isSupported = (eventName in el);
1285 // if ( !isSupported ) {
1286 // el.setAttribute(eventName, "return;");
1287 // isSupported = typeof el[eventName] === "function";
1288 // }
1289 // el = null;
1291 // return isSupported;
1292 // };
1294 jQuery.support.submitBubbles = false;
1295 jQuery.support.changeBubbles = false;
1297 // // release memory in IE
1298 // root = script = div = all = a = null;
1299 })();
1301 jQuery.props = {
1302 "for": "htmlFor",
1303 "class": "className",
1304 readonly: "readOnly",
1305 maxlength: "maxLength",
1306 cellspacing: "cellSpacing",
1307 rowspan: "rowSpan",
1308 colspan: "colSpan",
1309 tabindex: "tabIndex",
1310 usemap: "useMap",
1311 frameborder: "frameBorder"
1313 var expando = "jQuery" + now(), uuid = 0, windowData = {};
1314 var emptyObject = {};
1316 jQuery.extend({
1317 cache: {},
1319 expando:expando,
1321 // The following elements throw uncatchable exceptions if you
1322 // attempt to add expando properties to them.
1323 noData: {
1324 "embed": true,
1325 "object": true,
1326 "applet": true
1329 data: function( elem, name, data ) {
1330 /// <summary>
1331 /// Store arbitrary data associated with the specified element.
1332 /// </summary>
1333 /// <param name="elem" type="Element">
1334 /// The DOM element to associate with the data.
1335 /// </param>
1336 /// <param name="name" type="String">
1337 /// A string naming the piece of data to set.
1338 /// </param>
1339 /// <param name="value" type="Object">
1340 /// The new data value.
1341 /// </param>
1342 /// <returns type="jQuery" />
1344 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
1345 return;
1348 elem = elem == window ?
1349 windowData :
1350 elem;
1352 var id = elem[ expando ], cache = jQuery.cache, thisCache;
1354 // Handle the case where there's no name immediately
1355 if ( !name && !id ) {
1356 return null;
1359 // Compute a unique ID for the element
1360 if ( !id ) {
1361 id = ++uuid;
1364 // Avoid generating a new cache unless none exists and we
1365 // want to manipulate it.
1366 if ( typeof name === "object" ) {
1367 elem[ expando ] = id;
1368 thisCache = cache[ id ] = jQuery.extend(true, {}, name);
1369 } else if ( cache[ id ] ) {
1370 thisCache = cache[ id ];
1371 } else if ( typeof data === "undefined" ) {
1372 thisCache = emptyObject;
1373 } else {
1374 thisCache = cache[ id ] = {};
1377 // Prevent overriding the named cache with undefined values
1378 if ( data !== undefined ) {
1379 elem[ expando ] = id;
1380 thisCache[ name ] = data;
1383 return typeof name === "string" ? thisCache[ name ] : thisCache;
1386 removeData: function( elem, name ) {
1387 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
1388 return;
1391 elem = elem == window ?
1392 windowData :
1393 elem;
1395 var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
1397 // If we want to remove a specific section of the element's data
1398 if ( name ) {
1399 if ( thisCache ) {
1400 // Remove the section of cache data
1401 delete thisCache[ name ];
1403 // If we've removed all the data, remove the element's cache
1404 if ( jQuery.isEmptyObject(thisCache) ) {
1405 jQuery.removeData( elem );
1409 // Otherwise, we want to remove all of the element's data
1410 } else {
1411 // Clean up the element expando
1412 try {
1413 delete elem[ expando ];
1414 } catch( e ) {
1415 // IE has trouble directly removing the expando
1416 // but it's ok with using removeAttribute
1417 if ( elem.removeAttribute ) {
1418 elem.removeAttribute( expando );
1422 // Completely remove the data cache
1423 delete cache[ id ];
1428 jQuery.fn.extend({
1429 data: function( key, value ) {
1430 /// <summary>
1431 /// Store arbitrary data associated with the matched elements.
1432 /// </summary>
1433 /// <param name="key" type="String">
1434 /// A string naming the piece of data to set.
1435 /// </param>
1436 /// <param name="value" type="Object">
1437 /// The new data value.
1438 /// </param>
1439 /// <returns type="jQuery" />
1441 if ( typeof key === "undefined" && this.length ) {
1442 return jQuery.data( this[0] );
1444 } else if ( typeof key === "object" ) {
1445 return this.each(function() {
1446 jQuery.data( this, key );
1450 var parts = key.split(".");
1451 parts[1] = parts[1] ? "." + parts[1] : "";
1453 if ( value === undefined ) {
1454 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1456 if ( data === undefined && this.length ) {
1457 data = jQuery.data( this[0], key );
1459 return data === undefined && parts[1] ?
1460 this.data( parts[0] ) :
1461 data;
1462 } else {
1463 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
1464 jQuery.data( this, key, value );
1469 removeData: function( key ) {
1470 return this.each(function() {
1471 jQuery.removeData( this, key );
1475 jQuery.extend({
1476 queue: function( elem, type, data ) {
1477 if ( !elem ) {
1478 return;
1481 type = (type || "fx") + "queue";
1482 var q = jQuery.data( elem, type );
1484 // Speed up dequeue by getting out quickly if this is just a lookup
1485 if ( !data ) {
1486 return q || [];
1489 if ( !q || jQuery.isArray(data) ) {
1490 q = jQuery.data( elem, type, jQuery.makeArray(data) );
1492 } else {
1493 q.push( data );
1496 return q;
1499 dequeue: function( elem, type ) {
1500 type = type || "fx";
1502 var queue = jQuery.queue( elem, type ), fn = queue.shift();
1504 // If the fx queue is dequeued, always remove the progress sentinel
1505 if ( fn === "inprogress" ) {
1506 fn = queue.shift();
1509 if ( fn ) {
1510 // Add a progress sentinel to prevent the fx queue from being
1511 // automatically dequeued
1512 if ( type === "fx" ) {
1513 queue.unshift("inprogress");
1516 fn.call(elem, function() {
1517 jQuery.dequeue(elem, type);
1523 jQuery.fn.extend({
1524 queue: function( type, data ) {
1525 /// <summary>
1526 /// 1: queue() - Returns a reference to the first element's queue (which is an array of functions).
1527 /// 2: queue(callback) - Adds a new function, to be executed, onto the end of the queue of all matched elements.
1528 /// 3: queue(queue) - Replaces the queue of all matched element with this new queue (the array of functions).
1529 /// </summary>
1530 /// <param name="type" type="Function">The function to add to the queue.</param>
1531 /// <returns type="jQuery" />
1533 if ( typeof type !== "string" ) {
1534 data = type;
1535 type = "fx";
1538 if ( data === undefined ) {
1539 return jQuery.queue( this[0], type );
1541 return this.each(function( i, elem ) {
1542 var queue = jQuery.queue( this, type, data );
1544 if ( type === "fx" && queue[0] !== "inprogress" ) {
1545 jQuery.dequeue( this, type );
1549 dequeue: function( type ) {
1550 /// <summary>
1551 /// Removes a queued function from the front of the queue and executes it.
1552 /// </summary>
1553 /// <param name="type" type="String" optional="true">The type of queue to access.</param>
1554 /// <returns type="jQuery" />
1556 return this.each(function() {
1557 jQuery.dequeue( this, type );
1561 // Based off of the plugin by Clint Helfers, with permission.
1562 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1563 delay: function( time, type ) {
1564 /// <summary>
1565 /// Set a timer to delay execution of subsequent items in the queue.
1566 /// </summary>
1567 /// <param name="time" type="Number">
1568 /// An integer indicating the number of milliseconds to delay execution of the next item in the queue.
1569 /// </param>
1570 /// <param name="type" type="String">
1571 /// A string containing the name of the queue. Defaults to fx, the standard effects queue.
1572 /// </param>
1573 /// <returns type="jQuery" />
1575 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1576 type = type || "fx";
1578 return this.queue( type, function() {
1579 var elem = this;
1580 setTimeout(function() {
1581 jQuery.dequeue( elem, type );
1582 }, time );
1586 clearQueue: function( type ) {
1587 /// <summary>
1588 /// Remove from the queue all items that have not yet been run.
1589 /// </summary>
1590 /// <param name="type" type="String" optional="true">
1591 /// A string containing the name of the queue. Defaults to fx, the standard effects queue.
1592 /// </param>
1593 /// <returns type="jQuery" />
1595 return this.queue( type || "fx", [] );
1598 var rclass = /[\n\t]/g,
1599 rspace = /\s+/,
1600 rreturn = /\r/g,
1601 rspecialurl = /href|src|style/,
1602 rtype = /(button|input)/i,
1603 rfocusable = /(button|input|object|select|textarea)/i,
1604 rclickable = /^(a|area)$/i,
1605 rradiocheck = /radio|checkbox/;
1607 jQuery.fn.extend({
1608 attr: function( name, value ) {
1609 /// <summary>
1610 /// Set a single property to a computed value, on all matched elements.
1611 /// Instead of a value, a function is provided, that computes the value.
1612 /// Part of DOM/Attributes
1613 /// </summary>
1614 /// <returns type="jQuery" />
1615 /// <param name="name" type="String">
1616 /// The name of the property to set.
1617 /// </param>
1618 /// <param name="value" type="Function">
1619 /// A function returning the value to set.
1620 /// </param>
1622 return access( this, name, value, true, jQuery.attr );
1625 removeAttr: function( name, fn ) {
1626 /// <summary>
1627 /// Remove an attribute from each of the matched elements.
1628 /// Part of DOM/Attributes
1629 /// </summary>
1630 /// <param name="name" type="String">
1631 /// An attribute to remove.
1632 /// </param>
1633 /// <returns type="jQuery" />
1635 return this.each(function(){
1636 jQuery.attr( this, name, "" );
1637 if ( this.nodeType === 1 ) {
1638 this.removeAttribute( name );
1643 addClass: function( value ) {
1644 /// <summary>
1645 /// Adds the specified class(es) to each of the set of matched elements.
1646 /// Part of DOM/Attributes
1647 /// </summary>
1648 /// <param name="value" type="String">
1649 /// One or more class names to be added to the class attribute of each matched element.
1650 /// </param>
1651 /// <returns type="jQuery" />
1653 if ( jQuery.isFunction(value) ) {
1654 return this.each(function(i) {
1655 var self = jQuery(this);
1656 self.addClass( value.call(this, i, self.attr("class")) );
1660 if ( value && typeof value === "string" ) {
1661 var classNames = (value || "").split( rspace );
1663 for ( var i = 0, l = this.length; i < l; i++ ) {
1664 var elem = this[i];
1666 if ( elem.nodeType === 1 ) {
1667 if ( !elem.className ) {
1668 elem.className = value;
1670 } else {
1671 var className = " " + elem.className + " ";
1672 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1673 if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
1674 elem.className += " " + classNames[c];
1682 return this;
1685 removeClass: function( value ) {
1686 /// <summary>
1687 /// Removes all or the specified class(es) from the set of matched elements.
1688 /// Part of DOM/Attributes
1689 /// </summary>
1690 /// <param name="value" type="String" optional="true">
1691 /// (Optional) A class name to be removed from the class attribute of each matched element.
1692 /// </param>
1693 /// <returns type="jQuery" />
1695 if ( jQuery.isFunction(value) ) {
1696 return this.each(function(i) {
1697 var self = jQuery(this);
1698 self.removeClass( value.call(this, i, self.attr("class")) );
1702 if ( (value && typeof value === "string") || value === undefined ) {
1703 var classNames = (value || "").split(rspace);
1705 for ( var i = 0, l = this.length; i < l; i++ ) {
1706 var elem = this[i];
1708 if ( elem.nodeType === 1 && elem.className ) {
1709 if ( value ) {
1710 var className = (" " + elem.className + " ").replace(rclass, " ");
1711 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1712 className = className.replace(" " + classNames[c] + " ", " ");
1714 elem.className = className.substring(1, className.length - 1);
1716 } else {
1717 elem.className = "";
1723 return this;
1726 toggleClass: function( value, stateVal ) {
1727 /// <summary>
1728 /// Add or remove a class from each element in the set of matched elements, depending
1729 /// on either the class's presence or the value of the switch argument.
1730 /// </summary>
1731 /// <param name="value" type="Object">
1732 /// A class name to be toggled for each element in the matched set.
1733 /// </param>
1734 /// <param name="stateVal" type="Object">
1735 /// A boolean value to determine whether the class should be added or removed.
1736 /// </param>
1737 /// <returns type="jQuery" />
1739 var type = typeof value, isBool = typeof stateVal === "boolean";
1741 if ( jQuery.isFunction( value ) ) {
1742 return this.each(function(i) {
1743 var self = jQuery(this);
1744 self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
1748 return this.each(function() {
1749 if ( type === "string" ) {
1750 // toggle individual class names
1751 var className, i = 0, self = jQuery(this),
1752 state = stateVal,
1753 classNames = value.split( rspace );
1755 while ( (className = classNames[ i++ ]) ) {
1756 // check each className given, space seperated list
1757 state = isBool ? state : !self.hasClass( className );
1758 self[ state ? "addClass" : "removeClass" ]( className );
1761 } else if ( type === "undefined" || type === "boolean" ) {
1762 if ( this.className ) {
1763 // store className if set
1764 jQuery.data( this, "__className__", this.className );
1767 // toggle whole className
1768 this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
1773 hasClass: function( selector ) {
1774 /// <summary>
1775 /// Checks the current selection against a class and returns whether at least one selection has a given class.
1776 /// </summary>
1777 /// <param name="selector" type="String">The class to check against</param>
1778 /// <returns type="Boolean">True if at least one element in the selection has the class, otherwise false.</returns>
1780 var className = " " + selector + " ";
1781 for ( var i = 0, l = this.length; i < l; i++ ) {
1782 if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
1783 return true;
1787 return false;
1790 val: function( value ) {
1791 /// <summary>
1792 /// Set the value of every matched element.
1793 /// Part of DOM/Attributes
1794 /// </summary>
1795 /// <returns type="jQuery" />
1796 /// <param name="value" type="String">
1797 /// A string of text or an array of strings to set as the value property of each
1798 /// matched element.
1799 /// </param>
1801 if ( value === undefined ) {
1802 var elem = this[0];
1804 if ( elem ) {
1805 if ( jQuery.nodeName( elem, "option" ) ) {
1806 return (elem.attributes.value || {}).specified ? elem.value : elem.text;
1809 // We need to handle select boxes special
1810 if ( jQuery.nodeName( elem, "select" ) ) {
1811 var index = elem.selectedIndex,
1812 values = [],
1813 options = elem.options,
1814 one = elem.type === "select-one";
1816 // Nothing was selected
1817 if ( index < 0 ) {
1818 return null;
1821 // Loop through all the selected options
1822 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
1823 var option = options[ i ];
1825 if ( option.selected ) {
1826 // Get the specifc value for the option
1827 value = jQuery(option).val();
1829 // We don't need an array for one selects
1830 if ( one ) {
1831 return value;
1834 // Multi-Selects return an array
1835 values.push( value );
1839 return values;
1842 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
1843 if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
1844 return elem.getAttribute("value") === null ? "on" : elem.value;
1848 // Everything else, we just grab the value
1849 return (elem.value || "").replace(rreturn, "");
1853 return undefined;
1856 var isFunction = jQuery.isFunction(value);
1858 return this.each(function(i) {
1859 var self = jQuery(this), val = value;
1861 if ( this.nodeType !== 1 ) {
1862 return;
1865 if ( isFunction ) {
1866 val = value.call(this, i, self.val());
1869 // Typecast each time if the value is a Function and the appended
1870 // value is therefore different each time.
1871 if ( typeof val === "number" ) {
1872 val += "";
1875 if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
1876 this.checked = jQuery.inArray( self.val(), val ) >= 0;
1878 } else if ( jQuery.nodeName( this, "select" ) ) {
1879 var values = jQuery.makeArray(val);
1881 jQuery( "option", this ).each(function() {
1882 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
1885 if ( !values.length ) {
1886 this.selectedIndex = -1;
1889 } else {
1890 this.value = val;
1896 jQuery.extend({
1897 attrFn: {
1898 val: true,
1899 css: true,
1900 html: true,
1901 text: true,
1902 data: true,
1903 width: true,
1904 height: true,
1905 offset: true
1908 attr: function( elem, name, value, pass ) {
1909 /// <summary>
1910 /// This method is internal.
1911 /// </summary>
1912 /// <private />
1914 // don't set attributes on text and comment nodes
1915 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
1916 return undefined;
1919 if ( pass && name in jQuery.attrFn ) {
1920 return jQuery(elem)[name](value);
1923 var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
1924 // Whether we are setting (or getting)
1925 set = value !== undefined;
1927 // Try to normalize/fix the name
1928 name = notxml && jQuery.props[ name ] || name;
1930 // Only do all the following if this is a node (faster for style)
1931 if ( elem.nodeType === 1 ) {
1932 // These attributes require special treatment
1933 var special = rspecialurl.test( name );
1935 // Safari mis-reports the default selected property of an option
1936 // Accessing the parent's selectedIndex property fixes it
1937 if ( name === "selected" && !jQuery.support.optSelected ) {
1938 var parent = elem.parentNode;
1939 if ( parent ) {
1940 parent.selectedIndex;
1942 // Make sure that it also works with optgroups, see #5701
1943 if ( parent.parentNode ) {
1944 parent.parentNode.selectedIndex;
1949 // If applicable, access the attribute via the DOM 0 way
1950 if ( name in elem && notxml && !special ) {
1951 if ( set ) {
1952 // We can't allow the type property to be changed (since it causes problems in IE)
1953 if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
1954 jQuery.error( "type property can't be changed" );
1957 elem[ name ] = value;
1960 // browsers index elements by id/name on forms, give priority to attributes.
1961 if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
1962 return elem.getAttributeNode( name ).nodeValue;
1965 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
1966 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
1967 if ( name === "tabIndex" ) {
1968 var attributeNode = elem.getAttributeNode( "tabIndex" );
1970 return attributeNode && attributeNode.specified ?
1971 attributeNode.value :
1972 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
1974 undefined;
1977 return elem[ name ];
1980 if ( !jQuery.support.style && notxml && name === "style" ) {
1981 if ( set ) {
1982 elem.style.cssText = "" + value;
1985 return elem.style.cssText;
1988 if ( set ) {
1989 // convert the value to a string (all browsers do this but IE) see #1070
1990 elem.setAttribute( name, "" + value );
1993 var attr = !jQuery.support.hrefNormalized && notxml && special ?
1994 // Some attributes require a special call on IE
1995 elem.getAttribute( name, 2 ) :
1996 elem.getAttribute( name );
1998 // Non-existent attributes return null, we normalize to undefined
1999 return attr === null ? undefined : attr;
2002 // elem is actually elem.style ... set the style
2003 // Using attr for specific style information is now deprecated. Use style insead.
2004 return jQuery.style( elem, name, value );
2007 var fcleanup = function( nm ) {
2008 return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
2009 return "\\" + ch;
2014 * A number of helper functions used for managing events.
2015 * Many of the ideas behind this code originated from
2016 * Dean Edwards' addEvent library.
2018 jQuery.event = {
2020 // Bind an event to an element
2021 // Original by Dean Edwards
2022 add: function( elem, types, handler, data ) {
2023 /// <summary>
2024 /// This method is internal.
2025 /// </summary>
2026 /// <private />
2028 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2029 return;
2032 // For whatever reason, IE has trouble passing the window object
2033 // around, causing it to be cloned in the process
2034 if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
2035 elem = window;
2038 // Make sure that the function being executed has a unique ID
2039 if ( !handler.guid ) {
2040 handler.guid = jQuery.guid++;
2043 // if data is passed, bind to handler
2044 if ( data !== undefined ) {
2045 // Create temporary function pointer to original handler
2046 var fn = handler;
2048 // Create unique handler function, wrapped around original handler
2049 handler = jQuery.proxy( fn );
2051 // Store data in unique handler
2052 handler.data = data;
2055 // Init the element's event structure
2056 var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
2057 handle = jQuery.data( elem, "handle" ), eventHandle;
2059 if ( !handle ) {
2060 eventHandle = function() {
2061 // Handle the second event of a trigger and when
2062 // an event is called after a page has unloaded
2063 return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
2064 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2065 undefined;
2068 handle = jQuery.data( elem, "handle", eventHandle );
2071 // If no handle is found then we must be trying to bind to one of the
2072 // banned noData elements
2073 if ( !handle ) {
2074 return;
2077 // Add elem as a property of the handle function
2078 // This is to prevent a memory leak with non-native
2079 // event in IE.
2080 handle.elem = elem;
2082 // Handle multiple events separated by a space
2083 // jQuery(...).bind("mouseover mouseout", fn);
2084 types = types.split( /\s+/ );
2086 var type, i = 0;
2088 while ( (type = types[ i++ ]) ) {
2089 // Namespaced event handlers
2090 var namespaces = type.split(".");
2091 type = namespaces.shift();
2093 if ( i > 1 ) {
2094 handler = jQuery.proxy( handler );
2096 if ( data !== undefined ) {
2097 handler.data = data;
2101 handler.type = namespaces.slice(0).sort().join(".");
2103 // Get the current list of functions bound to this event
2104 var handlers = events[ type ],
2105 special = this.special[ type ] || {};
2107 // Init the event handler queue
2108 if ( !handlers ) {
2109 handlers = events[ type ] = {};
2111 // Check for a special event handler
2112 // Only use addEventListener/attachEvent if the special
2113 // events handler returns false
2114 if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
2115 // Bind the global event handler to the element
2116 if ( elem.addEventListener ) {
2117 elem.addEventListener( type, handle, false );
2118 } else if ( elem.attachEvent ) {
2119 elem.attachEvent( "on" + type, handle );
2124 if ( special.add ) {
2125 var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
2126 if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
2127 modifiedHandler.guid = modifiedHandler.guid || handler.guid;
2128 modifiedHandler.data = modifiedHandler.data || handler.data;
2129 modifiedHandler.type = modifiedHandler.type || handler.type;
2130 handler = modifiedHandler;
2134 // Add the function to the element's handler list
2135 handlers[ handler.guid ] = handler;
2137 // Keep track of which events have been used, for global triggering
2138 this.global[ type ] = true;
2141 // Nullify elem to prevent memory leaks in IE
2142 elem = null;
2145 global: {},
2147 // Detach an event or set of events from an element
2148 remove: function( elem, types, handler ) {
2149 /// <summary>
2150 /// This method is internal.
2151 /// </summary>
2152 /// <private />
2154 // don't do events on text and comment nodes
2155 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2156 return;
2159 var events = jQuery.data( elem, "events" ), ret, type, fn;
2161 if ( events ) {
2162 // Unbind all events for the element
2163 if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
2164 for ( type in events ) {
2165 this.remove( elem, type + (types || "") );
2167 } else {
2168 // types is actually an event object here
2169 if ( types.type ) {
2170 handler = types.handler;
2171 types = types.type;
2174 // Handle multiple events separated by a space
2175 // jQuery(...).unbind("mouseover mouseout", fn);
2176 types = types.split(/\s+/);
2177 var i = 0;
2178 while ( (type = types[ i++ ]) ) {
2179 // Namespaced event handlers
2180 var namespaces = type.split(".");
2181 type = namespaces.shift();
2182 var all = !namespaces.length,
2183 cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
2184 namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
2185 special = this.special[ type ] || {};
2187 if ( events[ type ] ) {
2188 // remove the given handler for the given type
2189 if ( handler ) {
2190 fn = events[ type ][ handler.guid ];
2191 delete events[ type ][ handler.guid ];
2193 // remove all handlers for the given type
2194 } else {
2195 for ( var handle in events[ type ] ) {
2196 // Handle the removal of namespaced events
2197 if ( all || namespace.test( events[ type ][ handle ].type ) ) {
2198 delete events[ type ][ handle ];
2203 if ( special.remove ) {
2204 special.remove.call( elem, namespaces, fn);
2207 // remove generic event handler if no more handlers exist
2208 for ( ret in events[ type ] ) {
2209 break;
2211 if ( !ret ) {
2212 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2213 if ( elem.removeEventListener ) {
2214 elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
2215 } else if ( elem.detachEvent ) {
2216 elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
2219 ret = null;
2220 delete events[ type ];
2226 // Remove the expando if it's no longer used
2227 for ( ret in events ) {
2228 break;
2230 if ( !ret ) {
2231 var handle = jQuery.data( elem, "handle" );
2232 if ( handle ) {
2233 handle.elem = null;
2235 jQuery.removeData( elem, "events" );
2236 jQuery.removeData( elem, "handle" );
2241 // bubbling is internal
2242 trigger: function( event, data, elem /*, bubbling */ ) {
2243 /// <summary>
2244 /// This method is internal.
2245 /// </summary>
2246 /// <private />
2248 // Event object or event type
2249 var type = event.type || event,
2250 bubbling = arguments[3];
2252 if ( !bubbling ) {
2253 event = typeof event === "object" ?
2254 // jQuery.Event object
2255 event[expando] ? event :
2256 // Object literal
2257 jQuery.extend( jQuery.Event(type), event ) :
2258 // Just the event type (string)
2259 jQuery.Event(type);
2261 if ( type.indexOf("!") >= 0 ) {
2262 event.type = type = type.slice(0, -1);
2263 event.exclusive = true;
2266 // Handle a global trigger
2267 if ( !elem ) {
2268 // Don't bubble custom events when global (to avoid too much overhead)
2269 event.stopPropagation();
2271 // Only trigger if we've ever bound an event for it
2272 if ( this.global[ type ] ) {
2273 jQuery.each( jQuery.cache, function() {
2274 if ( this.events && this.events[type] ) {
2275 jQuery.event.trigger( event, data, this.handle.elem );
2281 // Handle triggering a single element
2283 // don't do events on text and comment nodes
2284 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
2285 return undefined;
2288 // Clean up in case it is reused
2289 event.result = undefined;
2290 event.target = elem;
2292 // Clone the incoming data, if any
2293 data = jQuery.makeArray( data );
2294 data.unshift( event );
2297 event.currentTarget = elem;
2299 // Trigger the event, it is assumed that "handle" is a function
2300 var handle = jQuery.data( elem, "handle" );
2301 if ( handle ) {
2302 handle.apply( elem, data );
2305 var parent = elem.parentNode || elem.ownerDocument;
2307 // Trigger an inline bound script
2308 try {
2309 if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
2310 if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
2311 event.result = false;
2315 // prevent IE from throwing an error for some elements with some event types, see #3533
2316 } catch (e) {}
2318 if ( !event.isPropagationStopped() && parent ) {
2319 jQuery.event.trigger( event, data, parent, true );
2321 } else if ( !event.isDefaultPrevented() ) {
2322 var target = event.target, old,
2323 isClick = jQuery.nodeName(target, "a") && type === "click";
2325 if ( !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
2326 try {
2327 if ( target[ type ] ) {
2328 // Make sure that we don't accidentally re-trigger the onFOO events
2329 old = target[ "on" + type ];
2331 if ( old ) {
2332 target[ "on" + type ] = null;
2335 this.triggered = true;
2336 target[ type ]();
2339 // prevent IE from throwing an error for some elements with some event types, see #3533
2340 } catch (e) {}
2342 if ( old ) {
2343 target[ "on" + type ] = old;
2346 this.triggered = false;
2351 handle: function( event ) {
2352 /// <summary>
2353 /// This method is internal.
2354 /// </summary>
2355 /// <private />
2357 // returned undefined or false
2358 var all, handlers;
2360 event = arguments[0] = jQuery.event.fix( event || window.event );
2361 event.currentTarget = this;
2363 // Namespaced event handlers
2364 var namespaces = event.type.split(".");
2365 event.type = namespaces.shift();
2367 // Cache this now, all = true means, any handler
2368 all = !namespaces.length && !event.exclusive;
2370 var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
2372 handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
2374 for ( var j in handlers ) {
2375 var handler = handlers[ j ];
2377 // Filter the functions by class
2378 if ( all || namespace.test(handler.type) ) {
2379 // Pass in a reference to the handler function itself
2380 // So that we can later remove it
2381 event.handler = handler;
2382 event.data = handler.data;
2384 var ret = handler.apply( this, arguments );
2386 if ( ret !== undefined ) {
2387 event.result = ret;
2388 if ( ret === false ) {
2389 event.preventDefault();
2390 event.stopPropagation();
2394 if ( event.isImmediatePropagationStopped() ) {
2395 break;
2401 return event.result;
2404 props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
2406 fix: function( event ) {
2407 /// <summary>
2408 /// This method is internal.
2409 /// </summary>
2410 /// <private />
2412 if ( event[ expando ] ) {
2413 return event;
2416 // store a copy of the original event object
2417 // and "clone" to set read-only properties
2418 var originalEvent = event;
2419 event = jQuery.Event( originalEvent );
2421 for ( var i = this.props.length, prop; i; ) {
2422 prop = this.props[ --i ];
2423 event[ prop ] = originalEvent[ prop ];
2426 // Fix target property, if necessary
2427 if ( !event.target ) {
2428 event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
2431 // check if target is a textnode (safari)
2432 if ( event.target.nodeType === 3 ) {
2433 event.target = event.target.parentNode;
2436 // Add relatedTarget, if necessary
2437 if ( !event.relatedTarget && event.fromElement ) {
2438 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
2441 // Calculate pageX/Y if missing and clientX/Y available
2442 if ( event.pageX == null && event.clientX != null ) {
2443 var doc = document.documentElement, body = document.body;
2444 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
2445 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
2448 // Add which for key events
2449 if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
2450 event.which = event.charCode || event.keyCode;
2453 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
2454 if ( !event.metaKey && event.ctrlKey ) {
2455 event.metaKey = event.ctrlKey;
2458 // Add which for click: 1 === left; 2 === middle; 3 === right
2459 // Note: button is not normalized, so don't use it
2460 if ( !event.which && event.button !== undefined ) {
2461 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
2464 return event;
2467 // Deprecated, use jQuery.guid instead
2468 guid: 1E8,
2470 // Deprecated, use jQuery.proxy instead
2471 proxy: jQuery.proxy,
2473 special: {
2474 ready: {
2475 // Make sure the ready event is setup
2476 setup: jQuery.bindReady,
2477 teardown: jQuery.noop
2480 live: {
2481 add: function( proxy, data, namespaces, live ) {
2482 jQuery.extend( proxy, data || {} );
2484 proxy.guid += data.selector + data.live;
2485 data.liveProxy = proxy;
2487 jQuery.event.add( this, data.live, liveHandler, data );
2491 remove: function( namespaces ) {
2492 if ( namespaces.length ) {
2493 var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
2495 jQuery.each( (jQuery.data(this, "events").live || {}), function() {
2496 if ( name.test(this.type) ) {
2497 remove++;
2501 if ( remove < 1 ) {
2502 jQuery.event.remove( this, namespaces[0], liveHandler );
2506 special: {}
2508 beforeunload: {
2509 setup: function( data, namespaces, fn ) {
2510 // We only want to do this special case on windows
2511 if ( this.setInterval ) {
2512 this.onbeforeunload = fn;
2515 return false;
2517 teardown: function( namespaces, fn ) {
2518 if ( this.onbeforeunload === fn ) {
2519 this.onbeforeunload = null;
2526 jQuery.Event = function( src ) {
2527 // Allow instantiation without the 'new' keyword
2528 if ( !this.preventDefault ) {
2529 return new jQuery.Event( src );
2532 // Event object
2533 if ( src && src.type ) {
2534 this.originalEvent = src;
2535 this.type = src.type;
2536 // Event type
2537 } else {
2538 this.type = src;
2541 // timeStamp is buggy for some events on Firefox(#3843)
2542 // So we won't rely on the native value
2543 this.timeStamp = now();
2545 // Mark it as fixed
2546 this[ expando ] = true;
2549 function returnFalse() {
2550 return false;
2552 function returnTrue() {
2553 return true;
2556 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
2557 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
2558 jQuery.Event.prototype = {
2559 preventDefault: function() {
2560 this.isDefaultPrevented = returnTrue;
2562 var e = this.originalEvent;
2563 if ( !e ) {
2564 return;
2567 // if preventDefault exists run it on the original event
2568 if ( e.preventDefault ) {
2569 e.preventDefault();
2571 // otherwise set the returnValue property of the original event to false (IE)
2572 e.returnValue = false;
2574 stopPropagation: function() {
2575 this.isPropagationStopped = returnTrue;
2577 var e = this.originalEvent;
2578 if ( !e ) {
2579 return;
2581 // if stopPropagation exists run it on the original event
2582 if ( e.stopPropagation ) {
2583 e.stopPropagation();
2585 // otherwise set the cancelBubble property of the original event to true (IE)
2586 e.cancelBubble = true;
2588 stopImmediatePropagation: function() {
2589 this.isImmediatePropagationStopped = returnTrue;
2590 this.stopPropagation();
2592 isDefaultPrevented: returnFalse,
2593 isPropagationStopped: returnFalse,
2594 isImmediatePropagationStopped: returnFalse
2597 // Checks if an event happened on an element within another element
2598 // Used in jQuery.event.special.mouseenter and mouseleave handlers
2599 var withinElement = function( event ) {
2600 // Check if mouse(over|out) are still within the same parent element
2601 var parent = event.relatedTarget;
2603 // Traverse up the tree
2604 while ( parent && parent !== this ) {
2605 // Firefox sometimes assigns relatedTarget a XUL element
2606 // which we cannot access the parentNode property of
2607 try {
2608 parent = parent.parentNode;
2610 // assuming we've left the element since we most likely mousedover a xul element
2611 } catch(e) {
2612 break;
2616 if ( parent !== this ) {
2617 // set the correct event type
2618 event.type = event.data;
2620 // handle event if we actually just moused on to a non sub-element
2621 jQuery.event.handle.apply( this, arguments );
2626 // In case of event delegation, we only need to rename the event.type,
2627 // liveHandler will take care of the rest.
2628 delegate = function( event ) {
2629 event.type = event.data;
2630 jQuery.event.handle.apply( this, arguments );
2633 // Create mouseenter and mouseleave events
2634 jQuery.each({
2635 mouseenter: "mouseover",
2636 mouseleave: "mouseout"
2637 }, function( orig, fix ) {
2638 jQuery.event.special[ orig ] = {
2639 setup: function( data ) {
2640 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
2642 teardown: function( data ) {
2643 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
2648 // submit delegation
2649 if ( !jQuery.support.submitBubbles ) {
2651 jQuery.event.special.submit = {
2652 setup: function( data, namespaces, fn ) {
2653 if ( this.nodeName.toLowerCase() !== "form" ) {
2654 jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
2655 var elem = e.target, type = elem.type;
2657 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
2658 return trigger( "submit", this, arguments );
2662 jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
2663 var elem = e.target, type = elem.type;
2665 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
2666 return trigger( "submit", this, arguments );
2670 } else {
2671 return false;
2675 remove: function( namespaces, fn ) {
2676 jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
2677 jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
2683 // change delegation, happens here so we have bind.
2684 if ( !jQuery.support.changeBubbles ) {
2686 var formElems = /textarea|input|select/i;
2688 function getVal( elem ) {
2689 var type = elem.type, val = elem.value;
2691 if ( type === "radio" || type === "checkbox" ) {
2692 val = elem.checked;
2694 } else if ( type === "select-multiple" ) {
2695 val = elem.selectedIndex > -1 ?
2696 jQuery.map( elem.options, function( elem ) {
2697 return elem.selected;
2698 }).join("-") :
2701 } else if ( elem.nodeName.toLowerCase() === "select" ) {
2702 val = elem.selectedIndex;
2705 return val;
2708 function testChange( e ) {
2709 var elem = e.target, data, val;
2711 if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
2712 return;
2715 data = jQuery.data( elem, "_change_data" );
2716 val = getVal(elem);
2718 // the current data will be also retrieved by beforeactivate
2719 if ( e.type !== "focusout" || elem.type !== "radio" ) {
2720 jQuery.data( elem, "_change_data", val );
2723 if ( data === undefined || val === data ) {
2724 return;
2727 if ( data != null || val ) {
2728 e.type = "change";
2729 return jQuery.event.trigger( e, arguments[1], elem );
2733 jQuery.event.special.change = {
2734 filters: {
2735 focusout: testChange,
2737 click: function( e ) {
2738 var elem = e.target, type = elem.type;
2740 if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
2741 return testChange.call( this, e );
2745 // Change has to be called before submit
2746 // Keydown will be called before keypress, which is used in submit-event delegation
2747 keydown: function( e ) {
2748 var elem = e.target, type = elem.type;
2750 if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
2751 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
2752 type === "select-multiple" ) {
2753 return testChange.call( this, e );
2757 // Beforeactivate happens also before the previous element is blurred
2758 // with this event you can't trigger a change event, but you can store
2759 // information/focus[in] is not needed anymore
2760 beforeactivate: function( e ) {
2761 var elem = e.target;
2763 if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
2764 jQuery.data( elem, "_change_data", getVal(elem) );
2768 setup: function( data, namespaces, fn ) {
2769 for ( var type in changeFilters ) {
2770 jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
2773 return formElems.test( this.nodeName );
2775 remove: function( namespaces, fn ) {
2776 for ( var type in changeFilters ) {
2777 jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
2780 return formElems.test( this.nodeName );
2784 var changeFilters = jQuery.event.special.change.filters;
2788 function trigger( type, elem, args ) {
2789 args[0].type = type;
2790 return jQuery.event.handle.apply( elem, args );
2793 // Create "bubbling" focus and blur events
2794 if ( document.addEventListener ) {
2795 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
2796 jQuery.event.special[ fix ] = {
2797 setup: function() {
2798 /// <summary>
2799 /// This method is internal.
2800 /// </summary>
2801 /// <private />
2803 this.addEventListener( orig, handler, true );
2805 teardown: function() {
2806 /// <summary>
2807 /// This method is internal.
2808 /// </summary>
2809 /// <private />
2811 this.removeEventListener( orig, handler, true );
2815 function handler( e ) {
2816 e = jQuery.event.fix( e );
2817 e.type = fix;
2818 return jQuery.event.handle.call( this, e );
2823 // jQuery.each(["bind", "one"], function( i, name ) {
2824 // jQuery.fn[ name ] = function( type, data, fn ) {
2825 // // Handle object literals
2826 // if ( typeof type === "object" ) {
2827 // for ( var key in type ) {
2828 // this[ name ](key, data, type[key], fn);
2829 // }
2830 // return this;
2831 // }
2833 // if ( jQuery.isFunction( data ) ) {
2834 // fn = data;
2835 // data = undefined;
2836 // }
2838 // var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
2839 // jQuery( this ).unbind( event, handler );
2840 // return fn.apply( this, arguments );
2841 // }) : fn;
2843 // return type === "unload" && name !== "one" ?
2844 // this.one( type, data, fn ) :
2845 // this.each(function() {
2846 // jQuery.event.add( this, type, handler, data );
2847 // });
2848 // };
2849 // });
2851 jQuery.fn[ "bind" ] = function( type, data, fn ) {
2852 /// <summary>
2853 /// Binds a handler to one or more events for each matched element. Can also bind custom events.
2854 /// </summary>
2855 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
2856 /// <param name="data" optional="true" type="Object">Additional data passed to the event handler as event.data</param>
2857 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
2859 // Handle object literals
2860 if ( typeof type === "object" ) {
2861 for ( var key in type ) {
2862 this[ "bind" ](key, data, type[key], fn);
2864 return this;
2867 if ( jQuery.isFunction( data ) ) {
2868 fn = data;
2869 data = undefined;
2872 var handler = "bind" === "one" ? jQuery.proxy( fn, function( event ) {
2873 jQuery( this ).unbind( event, handler );
2874 return fn.apply( this, arguments );
2875 }) : fn;
2877 return type === "unload" && "bind" !== "one" ?
2878 this.one( type, data, fn ) :
2879 this.each(function() {
2880 jQuery.event.add( this, type, handler, data );
2884 jQuery.fn[ "one" ] = function( type, data, fn ) {
2885 /// <summary>
2886 /// Binds a handler to one or more events to be executed exactly once for each matched element.
2887 /// </summary>
2888 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
2889 /// <param name="data" optional="true" type="Object">Additional data passed to the event handler as event.data</param>
2890 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
2892 // Handle object literals
2893 if ( typeof type === "object" ) {
2894 for ( var key in type ) {
2895 this[ "one" ](key, data, type[key], fn);
2897 return this;
2900 if ( jQuery.isFunction( data ) ) {
2901 fn = data;
2902 data = undefined;
2905 var handler = "one" === "one" ? jQuery.proxy( fn, function( event ) {
2906 jQuery( this ).unbind( event, handler );
2907 return fn.apply( this, arguments );
2908 }) : fn;
2910 return type === "unload" && "one" !== "one" ?
2911 this.one( type, data, fn ) :
2912 this.each(function() {
2913 jQuery.event.add( this, type, handler, data );
2917 jQuery.fn.extend({
2918 unbind: function( type, fn ) {
2919 /// <summary>
2920 /// Unbinds a handler from one or more events for each matched element.
2921 /// </summary>
2922 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
2923 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
2925 // Handle object literals
2926 if ( typeof type === "object" && !type.preventDefault ) {
2927 for ( var key in type ) {
2928 this.unbind(key, type[key]);
2930 return this;
2933 return this.each(function() {
2934 jQuery.event.remove( this, type, fn );
2937 trigger: function( type, data ) {
2938 /// <summary>
2939 /// Triggers a type of event on every matched element.
2940 /// </summary>
2941 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
2942 /// <param name="data" optional="true" type="Array">Additional data passed to the event handler as additional arguments.</param>
2943 /// <param name="fn" type="Function">This parameter is undocumented.</param>
2945 return this.each(function() {
2946 jQuery.event.trigger( type, data, this );
2950 triggerHandler: function( type, data ) {
2951 /// <summary>
2952 /// Triggers all bound event handlers on an element for a specific event type without executing the browser's default actions.
2953 /// </summary>
2954 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
2955 /// <param name="data" optional="true" type="Array">Additional data passed to the event handler as additional arguments.</param>
2956 /// <param name="fn" type="Function">This parameter is undocumented.</param>
2958 if ( this[0] ) {
2959 var event = jQuery.Event( type );
2960 event.preventDefault();
2961 event.stopPropagation();
2962 jQuery.event.trigger( event, data, this[0] );
2963 return event.result;
2967 toggle: function( fn ) {
2968 /// <summary>
2969 /// Toggles among two or more function calls every other click.
2970 /// </summary>
2971 /// <param name="fn" type="Function">The functions among which to toggle execution</param>
2973 // Save reference to arguments for access in closure
2974 var args = arguments, i = 1;
2976 // link all the functions, so any of them can unbind this click handler
2977 while ( i < args.length ) {
2978 jQuery.proxy( fn, args[ i++ ] );
2981 return this.click( jQuery.proxy( fn, function( event ) {
2982 // Figure out which function to execute
2983 var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
2984 jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
2986 // Make sure that clicks stop
2987 event.preventDefault();
2989 // and execute the function
2990 return args[ lastToggle ].apply( this, arguments ) || false;
2991 }));
2994 hover: function( fnOver, fnOut ) {
2995 /// <summary>
2996 /// Simulates hovering (moving the mouse on or off of an object).
2997 /// </summary>
2998 /// <param name="fnOver" type="Function">The function to fire when the mouse is moved over a matched element.</param>
2999 /// <param name="fnOut" type="Function">The function to fire when the mouse is moved off of a matched element.</param>
3001 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3005 // jQuery.each(["live", "die"], function( i, name ) {
3006 // jQuery.fn[ name ] = function( types, data, fn ) {
3007 // var type, i = 0;
3009 // if ( jQuery.isFunction( data ) ) {
3010 // fn = data;
3011 // data = undefined;
3012 // }
3014 // types = (types || "").split( /\s+/ );
3016 // while ( (type = types[ i++ ]) != null ) {
3017 // type = type === "focus" ? "focusin" : // focus --> focusin
3018 // type === "blur" ? "focusout" : // blur --> focusout
3019 // type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support
3020 // type;
3022 // if ( name === "live" ) {
3023 // // bind live handler
3024 // jQuery( this.context ).bind( liveConvert( type, this.selector ), {
3025 // data: data, selector: this.selector, live: type
3026 // }, fn );
3028 // } else {
3029 // // unbind live handler
3030 // jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
3031 // }
3032 // }
3034 // return this;
3035 // }
3036 // });
3038 jQuery.fn[ "live" ] = function( types, data, fn ) {
3039 /// <summary>
3040 /// Attach a handler to the event for all elements which match the current selector, now or
3041 /// in the future.
3042 /// </summary>
3043 /// <param name="types" type="String">
3044 /// A string containing a JavaScript event type, such as "click" or "keydown".
3045 /// </param>
3046 /// <param name="data" type="Object">
3047 /// A map of data that will be passed to the event handler.
3048 /// </param>
3049 /// <param name="fn" type="Function">
3050 /// A function to execute at the time the event is triggered.
3051 /// </param>
3052 /// <returns type="jQuery" />
3054 var type, i = 0;
3056 if ( jQuery.isFunction( data ) ) {
3057 fn = data;
3058 data = undefined;
3061 types = (types || "").split( /\s+/ );
3063 while ( (type = types[ i++ ]) != null ) {
3064 type = type === "focus" ? "focusin" : // focus --> focusin
3065 type === "blur" ? "focusout" : // blur --> focusout
3066 type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support
3067 type;
3069 if ( "live" === "live" ) {
3070 // bind live handler
3071 jQuery( this.context ).bind( liveConvert( type, this.selector ), {
3072 data: data, selector: this.selector, live: type
3073 }, fn );
3075 } else {
3076 // unbind live handler
3077 jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
3081 return this;
3084 jQuery.fn[ "die" ] = function( types, data, fn ) {
3085 /// <summary>
3086 /// Remove all event handlers previously attached using .live() from the elements.
3087 /// </summary>
3088 /// <param name="types" type="String">
3089 /// A string containing a JavaScript event type, such as click or keydown.
3090 /// </param>
3091 /// <param name="data" type="Object">
3092 /// The function that is to be no longer executed.
3093 /// </param>
3094 /// <returns type="jQuery" />
3096 var type, i = 0;
3098 if ( jQuery.isFunction( data ) ) {
3099 fn = data;
3100 data = undefined;
3103 types = (types || "").split( /\s+/ );
3105 while ( (type = types[ i++ ]) != null ) {
3106 type = type === "focus" ? "focusin" : // focus --> focusin
3107 type === "blur" ? "focusout" : // blur --> focusout
3108 type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support
3109 type;
3111 if ( "die" === "live" ) {
3112 // bind live handler
3113 jQuery( this.context ).bind( liveConvert( type, this.selector ), {
3114 data: data, selector: this.selector, live: type
3115 }, fn );
3117 } else {
3118 // unbind live handler
3119 jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
3123 return this;
3126 function liveHandler( event ) {
3127 var stop, elems = [], selectors = [], args = arguments,
3128 related, match, fn, elem, j, i, l, data,
3129 live = jQuery.extend({}, jQuery.data( this, "events" ).live);
3131 // Make sure we avoid non-left-click bubbling in Firefox (#3861)
3132 if ( event.button && event.type === "click" ) {
3133 return;
3136 for ( j in live ) {
3137 fn = live[j];
3138 if ( fn.live === event.type ||
3139 fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
3141 data = fn.data;
3142 if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
3143 !data.beforeFilter[event.type](event)) ) {
3144 selectors.push( fn.selector );
3146 } else {
3147 delete live[j];
3151 match = jQuery( event.target ).closest( selectors, event.currentTarget );
3153 for ( i = 0, l = match.length; i < l; i++ ) {
3154 for ( j in live ) {
3155 fn = live[j];
3156 elem = match[i].elem;
3157 related = null;
3159 if ( match[i].selector === fn.selector ) {
3160 // Those two events require additional checking
3161 if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
3162 related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
3165 if ( !related || related !== elem ) {
3166 elems.push({ elem: elem, fn: fn });
3172 for ( i = 0, l = elems.length; i < l; i++ ) {
3173 match = elems[i];
3174 event.currentTarget = match.elem;
3175 event.data = match.fn.data;
3176 if ( match.fn.apply( match.elem, args ) === false ) {
3177 stop = false;
3178 break;
3182 return stop;
3185 function liveConvert( type, selector ) {
3186 return "live." + (type ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
3189 // jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3190 // "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3191 // "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
3193 // // Handle event binding
3194 // jQuery.fn[ name ] = function( fn ) {
3195 // return fn ? this.bind( name, fn ) : this.trigger( name );
3196 // };
3198 // if ( jQuery.attrFn ) {
3199 // jQuery.attrFn[ name ] = true;
3200 // }
3201 // });
3203 jQuery.fn[ "blur" ] = function( fn ) {
3204 /// <summary>
3205 /// 1: blur() - Triggers the blur event of each matched element.
3206 /// 2: blur(fn) - Binds a function to the blur event of each matched element.
3207 /// </summary>
3208 /// <param name="fn" type="Function">The function to execute.</param>
3209 /// <returns type="jQuery" />
3211 return fn ? this.bind( "blur", fn ) : this.trigger( "blur" );
3214 jQuery.fn[ "focus" ] = function( fn ) {
3215 /// <summary>
3216 /// 1: focus() - Triggers the focus event of each matched element.
3217 /// 2: focus(fn) - Binds a function to the focus event of each matched element.
3218 /// </summary>
3219 /// <param name="fn" type="Function">The function to execute.</param>
3220 /// <returns type="jQuery" />
3222 return fn ? this.bind( "focus", fn ) : this.trigger( "focus" );
3225 jQuery.fn[ "focusin" ] = function( fn ) {
3226 /// <summary>
3227 /// Bind an event handler to the "focusin" JavaScript event.
3228 /// </summary>
3229 /// <param name="fn" type="Function">
3230 /// A function to execute each time the event is triggered.
3231 /// </param>
3232 /// <returns type="jQuery" />
3234 return fn ? this.bind( "focusin", fn ) : this.trigger( "focusin" );
3237 jQuery.fn[ "focusout" ] = function( fn ) {
3238 /// <summary>
3239 /// Bind an event handler to the "focusout" JavaScript event.
3240 /// </summary>
3241 /// <param name="fn" type="Function">
3242 /// A function to execute each time the event is triggered.
3243 /// </param>
3244 /// <returns type="jQuery" />
3246 return fn ? this.bind( "focusout", fn ) : this.trigger( "focusout" );
3249 jQuery.fn[ "load" ] = function( fn ) {
3250 /// <summary>
3251 /// 1: load() - Triggers the load event of each matched element.
3252 /// 2: load(fn) - Binds a function to the load event of each matched element.
3253 /// </summary>
3254 /// <param name="fn" type="Function">The function to execute.</param>
3255 /// <returns type="jQuery" />
3257 return fn ? this.bind( "load", fn ) : this.trigger( "load" );
3260 jQuery.fn[ "resize" ] = function( fn ) {
3261 /// <summary>
3262 /// 1: resize() - Triggers the resize event of each matched element.
3263 /// 2: resize(fn) - Binds a function to the resize event of each matched element.
3264 /// </summary>
3265 /// <param name="fn" type="Function">The function to execute.</param>
3266 /// <returns type="jQuery" />
3268 return fn ? this.bind( "resize", fn ) : this.trigger( "resize" );
3271 jQuery.fn[ "scroll" ] = function( fn ) {
3272 /// <summary>
3273 /// 1: scroll() - Triggers the scroll event of each matched element.
3274 /// 2: scroll(fn) - Binds a function to the scroll event of each matched element.
3275 /// </summary>
3276 /// <param name="fn" type="Function">The function to execute.</param>
3277 /// <returns type="jQuery" />
3279 return fn ? this.bind( "scroll", fn ) : this.trigger( "scroll" );
3282 jQuery.fn[ "unload" ] = function( fn ) {
3283 /// <summary>
3284 /// 1: unload() - Triggers the unload event of each matched element.
3285 /// 2: unload(fn) - Binds a function to the unload event of each matched element.
3286 /// </summary>
3287 /// <param name="fn" type="Function">The function to execute.</param>
3288 /// <returns type="jQuery" />
3290 return fn ? this.bind( "unload", fn ) : this.trigger( "unload" );
3293 jQuery.fn[ "click" ] = function( fn ) {
3294 /// <summary>
3295 /// 1: click() - Triggers the click event of each matched element.
3296 /// 2: click(fn) - Binds a function to the click event of each matched element.
3297 /// </summary>
3298 /// <param name="fn" type="Function">The function to execute.</param>
3299 /// <returns type="jQuery" />
3301 return fn ? this.bind( "click", fn ) : this.trigger( "click" );
3304 jQuery.fn[ "dblclick" ] = function( fn ) {
3305 /// <summary>
3306 /// 1: dblclick() - Triggers the dblclick event of each matched element.
3307 /// 2: dblclick(fn) - Binds a function to the dblclick event of each matched element.
3308 /// </summary>
3309 /// <param name="fn" type="Function">The function to execute.</param>
3310 /// <returns type="jQuery" />
3312 return fn ? this.bind( "dblclick", fn ) : this.trigger( "dblclick" );
3315 jQuery.fn[ "mousedown" ] = function( fn ) {
3316 /// <summary>
3317 /// Binds a function to the mousedown event of each matched element.
3318 /// </summary>
3319 /// <param name="fn" type="Function">The function to execute.</param>
3320 /// <returns type="jQuery" />
3322 return fn ? this.bind( "mousedown", fn ) : this.trigger( "mousedown" );
3325 jQuery.fn[ "mouseup" ] = function( fn ) {
3326 /// <summary>
3327 /// Bind a function to the mouseup event of each matched element.
3328 /// </summary>
3329 /// <param name="fn" type="Function">The function to execute.</param>
3330 /// <returns type="jQuery" />
3332 return fn ? this.bind( "mouseup", fn ) : this.trigger( "mouseup" );
3335 jQuery.fn[ "mousemove" ] = function( fn ) {
3336 /// <summary>
3337 /// Bind a function to the mousemove event of each matched element.
3338 /// </summary>
3339 /// <param name="fn" type="Function">The function to execute.</param>
3340 /// <returns type="jQuery" />
3342 return fn ? this.bind( "mousemove", fn ) : this.trigger( "mousemove" );
3345 jQuery.fn[ "mouseover" ] = function( fn ) {
3346 /// <summary>
3347 /// Bind a function to the mouseover event of each matched element.
3348 /// </summary>
3349 /// <param name="fn" type="Function">The function to execute.</param>
3350 /// <returns type="jQuery" />
3352 return fn ? this.bind( "mouseover", fn ) : this.trigger( "mouseover" );
3355 jQuery.fn[ "mouseout" ] = function( fn ) {
3356 /// <summary>
3357 /// Bind a function to the mouseout event of each matched element.
3358 /// </summary>
3359 /// <param name="fn" type="Function">The function to execute.</param>
3360 /// <returns type="jQuery" />
3362 return fn ? this.bind( "mouseout", fn ) : this.trigger( "mouseout" );
3365 jQuery.fn[ "mouseenter" ] = function( fn ) {
3366 /// <summary>
3367 /// Bind a function to the mouseenter event of each matched element.
3368 /// </summary>
3369 /// <param name="fn" type="Function">The function to execute.</param>
3370 /// <returns type="jQuery" />
3372 return fn ? this.bind( "mouseenter", fn ) : this.trigger( "mouseenter" );
3375 jQuery.fn[ "mouseleave" ] = function( fn ) {
3376 /// <summary>
3377 /// Bind a function to the mouseleave event of each matched element.
3378 /// </summary>
3379 /// <param name="fn" type="Function">The function to execute.</param>
3380 /// <returns type="jQuery" />
3382 return fn ? this.bind( "mouseleave", fn ) : this.trigger( "mouseleave" );
3385 jQuery.fn[ "change" ] = function( fn ) {
3386 /// <summary>
3387 /// 1: change() - Triggers the change event of each matched element.
3388 /// 2: change(fn) - Binds a function to the change event of each matched element.
3389 /// </summary>
3390 /// <param name="fn" type="Function">The function to execute.</param>
3391 /// <returns type="jQuery" />
3393 return fn ? this.bind( "change", fn ) : this.trigger( "change" );
3396 jQuery.fn[ "select" ] = function( fn ) {
3397 /// <summary>
3398 /// 1: select() - Triggers the select event of each matched element.
3399 /// 2: select(fn) - Binds a function to the select event of each matched element.
3400 /// </summary>
3401 /// <param name="fn" type="Function">The function to execute.</param>
3402 /// <returns type="jQuery" />
3404 return fn ? this.bind( "select", fn ) : this.trigger( "select" );
3407 jQuery.fn[ "submit" ] = function( fn ) {
3408 /// <summary>
3409 /// 1: submit() - Triggers the submit event of each matched element.
3410 /// 2: submit(fn) - Binds a function to the submit event of each matched element.
3411 /// </summary>
3412 /// <param name="fn" type="Function">The function to execute.</param>
3413 /// <returns type="jQuery" />
3415 return fn ? this.bind( "submit", fn ) : this.trigger( "submit" );
3418 jQuery.fn[ "keydown" ] = function( fn ) {
3419 /// <summary>
3420 /// 1: keydown() - Triggers the keydown event of each matched element.
3421 /// 2: keydown(fn) - Binds a function to the keydown event of each matched element.
3422 /// </summary>
3423 /// <param name="fn" type="Function">The function to execute.</param>
3424 /// <returns type="jQuery" />
3426 return fn ? this.bind( "keydown", fn ) : this.trigger( "keydown" );
3429 jQuery.fn[ "keypress" ] = function( fn ) {
3430 /// <summary>
3431 /// 1: keypress() - Triggers the keypress event of each matched element.
3432 /// 2: keypress(fn) - Binds a function to the keypress event of each matched element.
3433 /// </summary>
3434 /// <param name="fn" type="Function">The function to execute.</param>
3435 /// <returns type="jQuery" />
3437 return fn ? this.bind( "keypress", fn ) : this.trigger( "keypress" );
3440 jQuery.fn[ "keyup" ] = function( fn ) {
3441 /// <summary>
3442 /// 1: keyup() - Triggers the keyup event of each matched element.
3443 /// 2: keyup(fn) - Binds a function to the keyup event of each matched element.
3444 /// </summary>
3445 /// <param name="fn" type="Function">The function to execute.</param>
3446 /// <returns type="jQuery" />
3448 return fn ? this.bind( "keyup", fn ) : this.trigger( "keyup" );
3451 jQuery.fn[ "error" ] = function( fn ) {
3452 /// <summary>
3453 /// 1: error() - Triggers the error event of each matched element.
3454 /// 2: error(fn) - Binds a function to the error event of each matched element.
3455 /// </summary>
3456 /// <param name="fn" type="Function">The function to execute.</param>
3457 /// <returns type="jQuery" />
3459 return fn ? this.bind( "error", fn ) : this.trigger( "error" );
3462 // Prevent memory leaks in IE
3463 // Window isn't included so as not to unbind existing unload events
3464 // More info:
3465 // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
3466 if ( window.attachEvent && !window.addEventListener ) {
3467 window.attachEvent("onunload", function() {
3468 for ( var id in jQuery.cache ) {
3469 if ( jQuery.cache[ id ].handle ) {
3470 // Try/Catch is to handle iframes being unloaded, see #4280
3471 try {
3472 jQuery.event.remove( jQuery.cache[ id ].handle.elem );
3473 } catch(e) {}
3479 * Sizzle CSS Selector Engine - v1.0
3480 * Copyright 2009, The Dojo Foundation
3481 * Released under the MIT, BSD, and GPL Licenses.
3482 * More information: http://sizzlejs.com/
3484 (function(){
3486 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3487 done = 0,
3488 toString = Object.prototype.toString,
3489 hasDuplicate = false,
3490 baseHasDuplicate = true;
3492 // Here we check if the JavaScript engine is using some sort of
3493 // optimization where it does not always call our comparision
3494 // function. If that is the case, discard the hasDuplicate value.
3495 // Thus far that includes Google Chrome.
3496 [0, 0].sort(function(){
3497 baseHasDuplicate = false;
3498 return 0;
3501 var Sizzle = function(selector, context, results, seed) {
3502 results = results || [];
3503 var origContext = context = context || document;
3505 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3506 return [];
3509 if ( !selector || typeof selector !== "string" ) {
3510 return results;
3513 var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
3514 soFar = selector;
3516 // Reset the position of the chunker regexp (start from head)
3517 while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
3518 soFar = m[3];
3520 parts.push( m[1] );
3522 if ( m[2] ) {
3523 extra = m[3];
3524 break;
3528 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3529 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3530 set = posProcess( parts[0] + parts[1], context );
3531 } else {
3532 set = Expr.relative[ parts[0] ] ?
3533 [ context ] :
3534 Sizzle( parts.shift(), context );
3536 while ( parts.length ) {
3537 selector = parts.shift();
3539 if ( Expr.relative[ selector ] ) {
3540 selector += parts.shift();
3543 set = posProcess( selector, set );
3546 } else {
3547 // Take a shortcut and set the context if the root selector is an ID
3548 // (but not if it'll be faster if the inner selector is an ID)
3549 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3550 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3551 var ret = Sizzle.find( parts.shift(), context, contextXML );
3552 context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
3555 if ( context ) {
3556 var ret = seed ?
3557 { expr: parts.pop(), set: makeArray(seed) } :
3558 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3559 set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
3561 if ( parts.length > 0 ) {
3562 checkSet = makeArray(set);
3563 } else {
3564 prune = false;
3567 while ( parts.length ) {
3568 var cur = parts.pop(), pop = cur;
3570 if ( !Expr.relative[ cur ] ) {
3571 cur = "";
3572 } else {
3573 pop = parts.pop();
3576 if ( pop == null ) {
3577 pop = context;
3580 Expr.relative[ cur ]( checkSet, pop, contextXML );
3582 } else {
3583 checkSet = parts = [];
3587 if ( !checkSet ) {
3588 checkSet = set;
3591 if ( !checkSet ) {
3592 Sizzle.error( cur || selector );
3595 if ( toString.call(checkSet) === "[object Array]" ) {
3596 if ( !prune ) {
3597 results.push.apply( results, checkSet );
3598 } else if ( context && context.nodeType === 1 ) {
3599 for ( var i = 0; checkSet[i] != null; i++ ) {
3600 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
3601 results.push( set[i] );
3604 } else {
3605 for ( var i = 0; checkSet[i] != null; i++ ) {
3606 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
3607 results.push( set[i] );
3611 } else {
3612 makeArray( checkSet, results );
3615 if ( extra ) {
3616 Sizzle( extra, origContext, results, seed );
3617 Sizzle.uniqueSort( results );
3620 return results;
3623 Sizzle.uniqueSort = function(results){
3624 /// <summary>
3625 /// Removes all duplicate elements from an array of elements.
3626 /// </summary>
3627 /// <param name="array" type="Array&lt;Element&gt;">The array to translate</param>
3628 /// <returns type="Array&lt;Element&gt;">The array after translation.</returns>
3630 if ( sortOrder ) {
3631 hasDuplicate = baseHasDuplicate;
3632 results.sort(sortOrder);
3634 if ( hasDuplicate ) {
3635 for ( var i = 1; i < results.length; i++ ) {
3636 if ( results[i] === results[i-1] ) {
3637 results.splice(i--, 1);
3643 return results;
3646 Sizzle.matches = function(expr, set){
3647 return Sizzle(expr, null, null, set);
3650 Sizzle.find = function(expr, context, isXML){
3651 var set, match;
3653 if ( !expr ) {
3654 return [];
3657 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
3658 var type = Expr.order[i], match;
3660 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
3661 var left = match[1];
3662 match.splice(1,1);
3664 if ( left.substr( left.length - 1 ) !== "\\" ) {
3665 match[1] = (match[1] || "").replace(/\\/g, "");
3666 set = Expr.find[ type ]( match, context, isXML );
3667 if ( set != null ) {
3668 expr = expr.replace( Expr.match[ type ], "" );
3669 break;
3675 if ( !set ) {
3676 set = context.getElementsByTagName("*");
3679 return {set: set, expr: expr};
3682 Sizzle.filter = function(expr, set, inplace, not){
3683 var old = expr, result = [], curLoop = set, match, anyFound,
3684 isXMLFilter = set && set[0] && isXML(set[0]);
3686 while ( expr && set.length ) {
3687 for ( var type in Expr.filter ) {
3688 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
3689 var filter = Expr.filter[ type ], found, item, left = match[1];
3690 anyFound = false;
3692 match.splice(1,1);
3694 if ( left.substr( left.length - 1 ) === "\\" ) {
3695 continue;
3698 if ( curLoop === result ) {
3699 result = [];
3702 if ( Expr.preFilter[ type ] ) {
3703 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
3705 if ( !match ) {
3706 anyFound = found = true;
3707 } else if ( match === true ) {
3708 continue;
3712 if ( match ) {
3713 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
3714 if ( item ) {
3715 found = filter( item, match, i, curLoop );
3716 var pass = not ^ !!found;
3718 if ( inplace && found != null ) {
3719 if ( pass ) {
3720 anyFound = true;
3721 } else {
3722 curLoop[i] = false;
3724 } else if ( pass ) {
3725 result.push( item );
3726 anyFound = true;
3732 if ( found !== undefined ) {
3733 if ( !inplace ) {
3734 curLoop = result;
3737 expr = expr.replace( Expr.match[ type ], "" );
3739 if ( !anyFound ) {
3740 return [];
3743 break;
3748 // Improper expression
3749 if ( expr === old ) {
3750 if ( anyFound == null ) {
3751 Sizzle.error( expr );
3752 } else {
3753 break;
3757 old = expr;
3760 return curLoop;
3763 Sizzle.error = function( msg ) {
3764 throw "Syntax error, unrecognized expression: " + msg;
3767 var Expr = Sizzle.selectors = {
3768 order: [ "ID", "NAME", "TAG" ],
3769 match: {
3770 ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
3771 CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
3772 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
3773 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
3774 TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
3775 CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
3776 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
3777 PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
3779 leftMatch: {},
3780 attrMap: {
3781 "class": "className",
3782 "for": "htmlFor"
3784 attrHandle: {
3785 href: function(elem){
3786 return elem.getAttribute("href");
3789 relative: {
3790 "+": function(checkSet, part){
3791 var isPartStr = typeof part === "string",
3792 isTag = isPartStr && !/\W/.test(part),
3793 isPartStrNotTag = isPartStr && !isTag;
3795 if ( isTag ) {
3796 part = part.toLowerCase();
3799 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
3800 if ( (elem = checkSet[i]) ) {
3801 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
3803 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
3804 elem || false :
3805 elem === part;
3809 if ( isPartStrNotTag ) {
3810 Sizzle.filter( part, checkSet, true );
3813 ">": function(checkSet, part){
3814 var isPartStr = typeof part === "string";
3816 if ( isPartStr && !/\W/.test(part) ) {
3817 part = part.toLowerCase();
3819 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
3820 var elem = checkSet[i];
3821 if ( elem ) {
3822 var parent = elem.parentNode;
3823 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
3826 } else {
3827 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
3828 var elem = checkSet[i];
3829 if ( elem ) {
3830 checkSet[i] = isPartStr ?
3831 elem.parentNode :
3832 elem.parentNode === part;
3836 if ( isPartStr ) {
3837 Sizzle.filter( part, checkSet, true );
3841 "": function(checkSet, part, isXML){
3842 var doneName = done++, checkFn = dirCheck;
3844 if ( typeof part === "string" && !/\W/.test(part) ) {
3845 var nodeCheck = part = part.toLowerCase();
3846 checkFn = dirNodeCheck;
3849 checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
3851 "~": function(checkSet, part, isXML){
3852 var doneName = done++, checkFn = dirCheck;
3854 if ( typeof part === "string" && !/\W/.test(part) ) {
3855 var nodeCheck = part = part.toLowerCase();
3856 checkFn = dirNodeCheck;
3859 checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
3862 find: {
3863 ID: function(match, context, isXML){
3864 if ( typeof context.getElementById !== "undefined" && !isXML ) {
3865 var m = context.getElementById(match[1]);
3866 return m ? [m] : [];
3869 NAME: function(match, context){
3870 if ( typeof context.getElementsByName !== "undefined" ) {
3871 var ret = [], results = context.getElementsByName(match[1]);
3873 for ( var i = 0, l = results.length; i < l; i++ ) {
3874 if ( results[i].getAttribute("name") === match[1] ) {
3875 ret.push( results[i] );
3879 return ret.length === 0 ? null : ret;
3882 TAG: function(match, context){
3883 return context.getElementsByTagName(match[1]);
3886 preFilter: {
3887 CLASS: function(match, curLoop, inplace, result, not, isXML){
3888 match = " " + match[1].replace(/\\/g, "") + " ";
3890 if ( isXML ) {
3891 return match;
3894 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
3895 if ( elem ) {
3896 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
3897 if ( !inplace ) {
3898 result.push( elem );
3900 } else if ( inplace ) {
3901 curLoop[i] = false;
3906 return false;
3908 ID: function(match){
3909 return match[1].replace(/\\/g, "");
3911 TAG: function(match, curLoop){
3912 return match[1].toLowerCase();
3914 CHILD: function(match){
3915 if ( match[1] === "nth" ) {
3916 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
3917 var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
3918 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
3919 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
3921 // calculate the numbers (first)n+(last) including if they are negative
3922 match[2] = (test[1] + (test[2] || 1)) - 0;
3923 match[3] = test[3] - 0;
3926 // TODO: Move to normal caching system
3927 match[0] = done++;
3929 return match;
3931 ATTR: function(match, curLoop, inplace, result, not, isXML){
3932 var name = match[1].replace(/\\/g, "");
3934 if ( !isXML && Expr.attrMap[name] ) {
3935 match[1] = Expr.attrMap[name];
3938 if ( match[2] === "~=" ) {
3939 match[4] = " " + match[4] + " ";
3942 return match;
3944 PSEUDO: function(match, curLoop, inplace, result, not){
3945 if ( match[1] === "not" ) {
3946 // If we're dealing with a complex expression, or a simple one
3947 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
3948 match[3] = Sizzle(match[3], null, null, curLoop);
3949 } else {
3950 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
3951 if ( !inplace ) {
3952 result.push.apply( result, ret );
3954 return false;
3956 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
3957 return true;
3960 return match;
3962 POS: function(match){
3963 match.unshift( true );
3964 return match;
3967 filters: {
3968 enabled: function(elem){
3969 return elem.disabled === false && elem.type !== "hidden";
3971 disabled: function(elem){
3972 return elem.disabled === true;
3974 checked: function(elem){
3975 return elem.checked === true;
3977 selected: function(elem){
3978 // Accessing this property makes selected-by-default
3979 // options in Safari work properly
3980 elem.parentNode.selectedIndex;
3981 return elem.selected === true;
3983 parent: function(elem){
3984 return !!elem.firstChild;
3986 empty: function(elem){
3987 return !elem.firstChild;
3989 has: function(elem, i, match){
3990 /// <summary>
3991 /// Internal use only; use hasClass('class')
3992 /// </summary>
3993 /// <private />
3995 return !!Sizzle( match[3], elem ).length;
3997 header: function(elem){
3998 return /h\d/i.test( elem.nodeName );
4000 text: function(elem){
4001 return "text" === elem.type;
4003 radio: function(elem){
4004 return "radio" === elem.type;
4006 checkbox: function(elem){
4007 return "checkbox" === elem.type;
4009 file: function(elem){
4010 return "file" === elem.type;
4012 password: function(elem){
4013 return "password" === elem.type;
4015 submit: function(elem){
4016 return "submit" === elem.type;
4018 image: function(elem){
4019 return "image" === elem.type;
4021 reset: function(elem){
4022 return "reset" === elem.type;
4024 button: function(elem){
4025 return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
4027 input: function(elem){
4028 return /input|select|textarea|button/i.test(elem.nodeName);
4031 setFilters: {
4032 first: function(elem, i){
4033 return i === 0;
4035 last: function(elem, i, match, array){
4036 return i === array.length - 1;
4038 even: function(elem, i){
4039 return i % 2 === 0;
4041 odd: function(elem, i){
4042 return i % 2 === 1;
4044 lt: function(elem, i, match){
4045 return i < match[3] - 0;
4047 gt: function(elem, i, match){
4048 return i > match[3] - 0;
4050 nth: function(elem, i, match){
4051 return match[3] - 0 === i;
4053 eq: function(elem, i, match){
4054 return match[3] - 0 === i;
4057 filter: {
4058 PSEUDO: function(elem, match, i, array){
4059 var name = match[1], filter = Expr.filters[ name ];
4061 if ( filter ) {
4062 return filter( elem, i, match, array );
4063 } else if ( name === "contains" ) {
4064 return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
4065 } else if ( name === "not" ) {
4066 var not = match[3];
4068 for ( var i = 0, l = not.length; i < l; i++ ) {
4069 if ( not[i] === elem ) {
4070 return false;
4074 return true;
4075 } else {
4076 Sizzle.error( "Syntax error, unrecognized expression: " + name );
4079 CHILD: function(elem, match){
4080 var type = match[1], node = elem;
4081 switch (type) {
4082 case 'only':
4083 case 'first':
4084 while ( (node = node.previousSibling) ) {
4085 if ( node.nodeType === 1 ) {
4086 return false;
4089 if ( type === "first" ) {
4090 return true;
4092 node = elem;
4093 case 'last':
4094 while ( (node = node.nextSibling) ) {
4095 if ( node.nodeType === 1 ) {
4096 return false;
4099 return true;
4100 case 'nth':
4101 var first = match[2], last = match[3];
4103 if ( first === 1 && last === 0 ) {
4104 return true;
4107 var doneName = match[0],
4108 parent = elem.parentNode;
4110 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4111 var count = 0;
4112 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4113 if ( node.nodeType === 1 ) {
4114 node.nodeIndex = ++count;
4117 parent.sizcache = doneName;
4120 var diff = elem.nodeIndex - last;
4121 if ( first === 0 ) {
4122 return diff === 0;
4123 } else {
4124 return ( diff % first === 0 && diff / first >= 0 );
4128 ID: function(elem, match){
4129 return elem.nodeType === 1 && elem.getAttribute("id") === match;
4131 TAG: function(elem, match){
4132 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
4134 CLASS: function(elem, match){
4135 return (" " + (elem.className || elem.getAttribute("class")) + " ")
4136 .indexOf( match ) > -1;
4138 ATTR: function(elem, match){
4139 var name = match[1],
4140 result = Expr.attrHandle[ name ] ?
4141 Expr.attrHandle[ name ]( elem ) :
4142 elem[ name ] != null ?
4143 elem[ name ] :
4144 elem.getAttribute( name ),
4145 value = result + "",
4146 type = match[2],
4147 check = match[4];
4149 return result == null ?
4150 type === "!=" :
4151 type === "=" ?
4152 value === check :
4153 type === "*=" ?
4154 value.indexOf(check) >= 0 :
4155 type === "~=" ?
4156 (" " + value + " ").indexOf(check) >= 0 :
4157 !check ?
4158 value && result !== false :
4159 type === "!=" ?
4160 value !== check :
4161 type === "^=" ?
4162 value.indexOf(check) === 0 :
4163 type === "$=" ?
4164 value.substr(value.length - check.length) === check :
4165 type === "|=" ?
4166 value === check || value.substr(0, check.length + 1) === check + "-" :
4167 false;
4169 POS: function(elem, match, i, array){
4170 var name = match[2], filter = Expr.setFilters[ name ];
4172 if ( filter ) {
4173 return filter( elem, i, match, array );
4179 var origPOS = Expr.match.POS;
4181 for ( var type in Expr.match ) {
4182 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
4183 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
4184 return "\\" + (num - 0 + 1);
4185 }));
4188 var makeArray = function(array, results) {
4189 array = Array.prototype.slice.call( array, 0 );
4191 if ( results ) {
4192 results.push.apply( results, array );
4193 return results;
4196 return array;
4199 // Perform a simple check to determine if the browser is capable of
4200 // converting a NodeList to an array using builtin methods.
4201 try {
4202 Array.prototype.slice.call( document.documentElement.childNodes, 0 );
4204 // Provide a fallback method if it does not work
4205 } catch(e){
4206 makeArray = function(array, results) {
4207 var ret = results || [];
4209 if ( toString.call(array) === "[object Array]" ) {
4210 Array.prototype.push.apply( ret, array );
4211 } else {
4212 if ( typeof array.length === "number" ) {
4213 for ( var i = 0, l = array.length; i < l; i++ ) {
4214 ret.push( array[i] );
4216 } else {
4217 for ( var i = 0; array[i]; i++ ) {
4218 ret.push( array[i] );
4223 return ret;
4227 var sortOrder;
4229 if ( document.documentElement.compareDocumentPosition ) {
4230 sortOrder = function( a, b ) {
4231 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4232 if ( a == b ) {
4233 hasDuplicate = true;
4235 return a.compareDocumentPosition ? -1 : 1;
4238 var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
4239 if ( ret === 0 ) {
4240 hasDuplicate = true;
4242 return ret;
4244 } else if ( "sourceIndex" in document.documentElement ) {
4245 sortOrder = function( a, b ) {
4246 if ( !a.sourceIndex || !b.sourceIndex ) {
4247 if ( a == b ) {
4248 hasDuplicate = true;
4250 return a.sourceIndex ? -1 : 1;
4253 var ret = a.sourceIndex - b.sourceIndex;
4254 if ( ret === 0 ) {
4255 hasDuplicate = true;
4257 return ret;
4259 } else if ( document.createRange ) {
4260 sortOrder = function( a, b ) {
4261 if ( !a.ownerDocument || !b.ownerDocument ) {
4262 if ( a == b ) {
4263 hasDuplicate = true;
4265 return a.ownerDocument ? -1 : 1;
4268 var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
4269 aRange.setStart(a, 0);
4270 aRange.setEnd(a, 0);
4271 bRange.setStart(b, 0);
4272 bRange.setEnd(b, 0);
4273 var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
4274 if ( ret === 0 ) {
4275 hasDuplicate = true;
4277 return ret;
4281 // Utility function for retreiving the text value of an array of DOM nodes
4282 function getText( elems ) {
4283 var ret = "", elem;
4285 for ( var i = 0; elems[i]; i++ ) {
4286 elem = elems[i];
4288 // Get the text from text nodes and CDATA nodes
4289 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
4290 ret += elem.nodeValue;
4292 // Traverse everything else, except comment nodes
4293 } else if ( elem.nodeType !== 8 ) {
4294 ret += getText( elem.childNodes );
4298 return ret;
4301 // [vsdoc] The following function has been modified for IntelliSense.
4302 // Check to see if the browser returns elements by name when
4303 // querying by getElementById (and provide a workaround)
4304 (function(){
4305 // We're going to inject a fake input element with a specified name
4306 // var form = document.createElement("div"),
4307 // id = "script" + (new Date).getTime();
4308 // form.innerHTML = "<a name='" + id + "'/>";
4310 // // Inject it into the root element, check its status, and remove it quickly
4311 // var root = document.documentElement;
4312 // root.insertBefore( form, root.firstChild );
4314 // The workaround has to do additional checks after a getElementById
4315 // Which slows things down for other browsers (hence the branching)
4316 // if ( document.getElementById( id ) ) {
4317 Expr.find.ID = function(match, context, isXML){
4318 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4319 var m = context.getElementById(match[1]);
4320 return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
4324 Expr.filter.ID = function(elem, match){
4325 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4326 return elem.nodeType === 1 && node && node.nodeValue === match;
4328 // }
4330 // root.removeChild( form );
4331 root = form = null; // release memory in IE
4332 })();
4334 // [vsdoc] The following function has been modified for IntelliSense.
4335 (function(){
4336 // Check to see if the browser returns only elements
4337 // when doing getElementsByTagName("*")
4339 // Create a fake element
4340 // var div = document.createElement("div");
4341 // div.appendChild( document.createComment("") );
4343 // Make sure no comments are found
4344 // if ( div.getElementsByTagName("*").length > 0 ) {
4345 Expr.find.TAG = function(match, context){
4346 var results = context.getElementsByTagName(match[1]);
4348 // Filter out possible comments
4349 if ( match[1] === "*" ) {
4350 var tmp = [];
4352 for ( var i = 0; results[i]; i++ ) {
4353 if ( results[i].nodeType === 1 ) {
4354 tmp.push( results[i] );
4358 results = tmp;
4361 return results;
4363 // }
4365 // Check to see if an attribute returns normalized href attributes
4366 // div.innerHTML = "<a href='#'></a>";
4367 // if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4368 // div.firstChild.getAttribute("href") !== "#" ) {
4369 Expr.attrHandle.href = function(elem){
4370 return elem.getAttribute("href", 2);
4372 // }
4374 div = null; // release memory in IE
4375 })();
4377 if ( document.querySelectorAll ) {
4378 (function(){
4379 var oldSizzle = Sizzle, div = document.createElement("div");
4380 div.innerHTML = "<p class='TEST'></p>";
4382 // Safari can't handle uppercase or unicode characters when
4383 // in quirks mode.
4384 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4385 return;
4388 Sizzle = function(query, context, extra, seed){
4389 context = context || document;
4391 // Only use querySelectorAll on non-XML documents
4392 // (ID selectors don't work in non-HTML documents)
4393 if ( !seed && context.nodeType === 9 && !isXML(context) ) {
4394 try {
4395 return makeArray( context.querySelectorAll(query), extra );
4396 } catch(e){}
4399 return oldSizzle(query, context, extra, seed);
4402 for ( var prop in oldSizzle ) {
4403 Sizzle[ prop ] = oldSizzle[ prop ];
4406 div = null; // release memory in IE
4407 })();
4410 (function(){
4411 var div = document.createElement("div");
4413 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
4415 // Opera can't find a second classname (in 9.6)
4416 // Also, make sure that getElementsByClassName actually exists
4417 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
4418 return;
4421 // Safari caches class attributes, doesn't catch changes (in 3.2)
4422 div.lastChild.className = "e";
4424 if ( div.getElementsByClassName("e").length === 1 ) {
4425 return;
4428 Expr.order.splice(1, 0, "CLASS");
4429 Expr.find.CLASS = function(match, context, isXML) {
4430 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
4431 return context.getElementsByClassName(match[1]);
4435 div = null; // release memory in IE
4436 })();
4438 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
4439 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4440 var elem = checkSet[i];
4441 if ( elem ) {
4442 elem = elem[dir];
4443 var match = false;
4445 while ( elem ) {
4446 if ( elem.sizcache === doneName ) {
4447 match = checkSet[elem.sizset];
4448 break;
4451 if ( elem.nodeType === 1 && !isXML ){
4452 elem.sizcache = doneName;
4453 elem.sizset = i;
4456 if ( elem.nodeName.toLowerCase() === cur ) {
4457 match = elem;
4458 break;
4461 elem = elem[dir];
4464 checkSet[i] = match;
4469 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
4470 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4471 var elem = checkSet[i];
4472 if ( elem ) {
4473 elem = elem[dir];
4474 var match = false;
4476 while ( elem ) {
4477 if ( elem.sizcache === doneName ) {
4478 match = checkSet[elem.sizset];
4479 break;
4482 if ( elem.nodeType === 1 ) {
4483 if ( !isXML ) {
4484 elem.sizcache = doneName;
4485 elem.sizset = i;
4487 if ( typeof cur !== "string" ) {
4488 if ( elem === cur ) {
4489 match = true;
4490 break;
4493 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
4494 match = elem;
4495 break;
4499 elem = elem[dir];
4502 checkSet[i] = match;
4507 var contains = document.compareDocumentPosition ? function(a, b){
4508 /// <summary>
4509 /// Check to see if a DOM node is within another DOM node.
4510 /// </summary>
4511 /// <param name="a" type="Object">
4512 /// The DOM element that may contain the other element.
4513 /// </param>
4514 /// <param name="b" type="Object">
4515 /// The DOM node that may be contained by the other element.
4516 /// </param>
4517 /// <returns type="Boolean" />
4519 return a.compareDocumentPosition(b) & 16;
4520 } : function(a, b){
4521 /// <summary>
4522 /// Check to see if a DOM node is within another DOM node.
4523 /// </summary>
4524 /// <param name="a" type="Object">
4525 /// The DOM element that may contain the other element.
4526 /// </param>
4527 /// <param name="b" type="Object">
4528 /// The DOM node that may be contained by the other element.
4529 /// </param>
4530 /// <returns type="Boolean" />
4532 return a !== b && (a.contains ? a.contains(b) : true);
4535 var isXML = function(elem){
4536 /// <summary>
4537 /// Determines if the parameter passed is an XML document.
4538 /// </summary>
4539 /// <param name="elem" type="Object">The object to test</param>
4540 /// <returns type="Boolean">True if the parameter is an XML document; otherwise false.</returns>
4542 // documentElement is verified for cases where it doesn't yet exist
4543 // (such as loading iframes in IE - #4833)
4544 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
4545 return documentElement ? documentElement.nodeName !== "HTML" : false;
4548 var posProcess = function(selector, context){
4549 var tmpSet = [], later = "", match,
4550 root = context.nodeType ? [context] : context;
4552 // Position selectors must be done after the filter
4553 // And so must :not(positional) so we move all PSEUDOs to the end
4554 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
4555 later += match[0];
4556 selector = selector.replace( Expr.match.PSEUDO, "" );
4559 selector = Expr.relative[selector] ? selector + "*" : selector;
4561 for ( var i = 0, l = root.length; i < l; i++ ) {
4562 Sizzle( selector, root[i], tmpSet );
4565 return Sizzle.filter( later, tmpSet );
4568 // EXPOSE
4569 jQuery.find = Sizzle;
4570 jQuery.expr = Sizzle.selectors;
4571 jQuery.expr[":"] = jQuery.expr.filters;
4572 jQuery.unique = Sizzle.uniqueSort;
4573 jQuery.getText = getText;
4574 jQuery.isXMLDoc = isXML;
4575 jQuery.contains = contains;
4577 return;
4579 window.Sizzle = Sizzle;
4581 })();
4582 var runtil = /Until$/,
4583 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
4584 // Note: This RegExp should be improved, or likely pulled from Sizzle
4585 rmultiselector = /,/,
4586 slice = Array.prototype.slice;
4588 // Implement the identical functionality for filter and not
4589 var winnow = function( elements, qualifier, keep ) {
4590 if ( jQuery.isFunction( qualifier ) ) {
4591 return jQuery.grep(elements, function( elem, i ) {
4592 return !!qualifier.call( elem, i, elem ) === keep;
4595 } else if ( qualifier.nodeType ) {
4596 return jQuery.grep(elements, function( elem, i ) {
4597 return (elem === qualifier) === keep;
4600 } else if ( typeof qualifier === "string" ) {
4601 var filtered = jQuery.grep(elements, function( elem ) {
4602 return elem.nodeType === 1;
4605 if ( isSimple.test( qualifier ) ) {
4606 return jQuery.filter(qualifier, filtered, !keep);
4607 } else {
4608 qualifier = jQuery.filter( qualifier, filtered );
4612 return jQuery.grep(elements, function( elem, i ) {
4613 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
4617 jQuery.fn.extend({
4618 find: function( selector ) {
4619 /// <summary>
4620 /// Searches for all elements that match the specified expression.
4621 /// This method is a good way to find additional descendant
4622 /// elements with which to process.
4623 /// All searching is done using a jQuery expression. The expression can be
4624 /// written using CSS 1-3 Selector syntax, or basic XPath.
4625 /// Part of DOM/Traversing
4626 /// </summary>
4627 /// <returns type="jQuery" />
4628 /// <param name="selector" type="String">
4629 /// An expression to search with.
4630 /// </param>
4631 /// <returns type="jQuery" />
4633 var ret = this.pushStack( "", "find", selector ), length = 0;
4635 for ( var i = 0, l = this.length; i < l; i++ ) {
4636 length = ret.length;
4637 jQuery.find( selector, this[i], ret );
4639 if ( i > 0 ) {
4640 // Make sure that the results are unique
4641 for ( var n = length; n < ret.length; n++ ) {
4642 for ( var r = 0; r < length; r++ ) {
4643 if ( ret[r] === ret[n] ) {
4644 ret.splice(n--, 1);
4645 break;
4652 return ret;
4655 has: function( target ) {
4656 /// <summary>
4657 /// Reduce the set of matched elements to those that have a descendant that matches the
4658 /// selector or DOM element.
4659 /// </summary>
4660 /// <param name="target" type="String">
4661 /// A string containing a selector expression to match elements against.
4662 /// </param>
4663 /// <returns type="jQuery" />
4665 var targets = jQuery( target );
4666 return this.filter(function() {
4667 for ( var i = 0, l = targets.length; i < l; i++ ) {
4668 if ( jQuery.contains( this, targets[i] ) ) {
4669 return true;
4675 not: function( selector ) {
4676 /// <summary>
4677 /// Removes any elements inside the array of elements from the set
4678 /// of matched elements. This method is used to remove one or more
4679 /// elements from a jQuery object.
4680 /// Part of DOM/Traversing
4681 /// </summary>
4682 /// <param name="selector" type="jQuery">
4683 /// A set of elements to remove from the jQuery set of matched elements.
4684 /// </param>
4685 /// <returns type="jQuery" />
4687 return this.pushStack( winnow(this, selector, false), "not", selector);
4690 filter: function( selector ) {
4691 /// <summary>
4692 /// Removes all elements from the set of matched elements that do not
4693 /// pass the specified filter. This method is used to narrow down
4694 /// the results of a search.
4695 /// })
4696 /// Part of DOM/Traversing
4697 /// </summary>
4698 /// <returns type="jQuery" />
4699 /// <param name="selector" type="Function">
4700 /// A function to use for filtering
4701 /// </param>
4702 /// <returns type="jQuery" />
4704 return this.pushStack( winnow(this, selector, true), "filter", selector );
4707 is: function( selector ) {
4708 /// <summary>
4709 /// Checks the current selection against an expression and returns true,
4710 /// if at least one element of the selection fits the given expression.
4711 /// Does return false, if no element fits or the expression is not valid.
4712 /// filter(String) is used internally, therefore all rules that apply there
4713 /// apply here, too.
4714 /// Part of DOM/Traversing
4715 /// </summary>
4716 /// <returns type="Boolean" />
4717 /// <param name="expr" type="String">
4718 /// The expression with which to filter
4719 /// </param>
4721 return !!selector && jQuery.filter( selector, this ).length > 0;
4724 closest: function( selectors, context ) {
4725 /// <summary>
4726 /// Get a set of elements containing the closest parent element that matches the specified selector, the starting element included.
4727 /// </summary>
4728 /// <param name="selectors" type="String">
4729 /// A string containing a selector expression to match elements against.
4730 /// </param>
4731 /// <param name="context" type="Element">
4732 /// A DOM element within which a matching element may be found. If no context is passed
4733 /// in then the context of the jQuery set will be used instead.
4734 /// </param>
4735 /// <returns type="jQuery" />
4737 if ( jQuery.isArray( selectors ) ) {
4738 var ret = [], cur = this[0], match, matches = {}, selector;
4740 if ( cur && selectors.length ) {
4741 for ( var i = 0, l = selectors.length; i < l; i++ ) {
4742 selector = selectors[i];
4744 if ( !matches[selector] ) {
4745 matches[selector] = jQuery.expr.match.POS.test( selector ) ?
4746 jQuery( selector, context || this.context ) :
4747 selector;
4751 while ( cur && cur.ownerDocument && cur !== context ) {
4752 for ( selector in matches ) {
4753 match = matches[selector];
4755 if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
4756 ret.push({ selector: selector, elem: cur });
4757 delete matches[selector];
4760 cur = cur.parentNode;
4764 return ret;
4767 var pos = jQuery.expr.match.POS.test( selectors ) ?
4768 jQuery( selectors, context || this.context ) : null;
4770 return this.map(function( i, cur ) {
4771 while ( cur && cur.ownerDocument && cur !== context ) {
4772 if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
4773 return cur;
4775 cur = cur.parentNode;
4777 return null;
4781 // Determine the position of an element within
4782 // the matched set of elements
4783 index: function( elem ) {
4784 /// <summary>
4785 /// Searches every matched element for the object and returns
4786 /// the index of the element, if found, starting with zero.
4787 /// Returns -1 if the object wasn't found.
4788 /// Part of Core
4789 /// </summary>
4790 /// <returns type="Number" />
4791 /// <param name="elem" type="Element">
4792 /// Object to search for
4793 /// </param>
4795 if ( !elem || typeof elem === "string" ) {
4796 return jQuery.inArray( this[0],
4797 // If it receives a string, the selector is used
4798 // If it receives nothing, the siblings are used
4799 elem ? jQuery( elem ) : this.parent().children() );
4801 // Locate the position of the desired element
4802 return jQuery.inArray(
4803 // If it receives a jQuery object, the first element is used
4804 elem.jquery ? elem[0] : elem, this );
4807 add: function( selector, context ) {
4808 /// <summary>
4809 /// Adds one or more Elements to the set of matched elements.
4810 /// Part of DOM/Traversing
4811 /// </summary>
4812 /// <param name="selector" type="String">
4813 /// A string containing a selector expression to match additional elements against.
4814 /// </param>
4815 /// <param name="context" type="Element">
4816 /// Add some elements rooted against the specified context.
4817 /// </param>
4818 /// <returns type="jQuery" />
4820 var set = typeof selector === "string" ?
4821 jQuery( selector, context || this.context ) :
4822 jQuery.makeArray( selector ),
4823 all = jQuery.merge( this.get(), set );
4825 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
4826 all :
4827 jQuery.unique( all ) );
4830 andSelf: function() {
4831 /// <summary>
4832 /// Adds the previous selection to the current selection.
4833 /// </summary>
4834 /// <returns type="jQuery" />
4836 return this.add( this.prevObject );
4840 // A painfully simple check to see if an element is disconnected
4841 // from a document (should be improved, where feasible).
4842 function isDisconnected( node ) {
4843 return !node || !node.parentNode || node.parentNode.nodeType === 11;
4846 jQuery.each({
4847 parent: function( elem ) {
4848 var parent = elem.parentNode;
4849 return parent && parent.nodeType !== 11 ? parent : null;
4851 parents: function( elem ) {
4852 return jQuery.dir( elem, "parentNode" );
4854 next: function( elem ) {
4855 return jQuery.nth( elem, 2, "nextSibling" );
4857 prev: function( elem ) {
4858 return jQuery.nth( elem, 2, "previousSibling" );
4860 nextAll: function( elem ) {
4861 return jQuery.dir( elem, "nextSibling" );
4863 prevAll: function( elem ) {
4864 return jQuery.dir( elem, "previousSibling" );
4866 siblings: function( elem ) {
4867 return jQuery.sibling( elem.parentNode.firstChild, elem );
4869 children: function( elem ) {
4870 return jQuery.sibling( elem.firstChild );
4872 contents: function( elem ) {
4873 return jQuery.nodeName( elem, "iframe" ) ?
4874 elem.contentDocument || elem.contentWindow.document :
4875 jQuery.makeArray( elem.childNodes );
4877 }, function( name, fn ) {
4878 jQuery.fn[ name ] = function( until, selector ) {
4879 var ret = jQuery.map( this, fn, until );
4881 if ( !runtil.test( name ) ) {
4882 selector = until;
4885 if ( selector && typeof selector === "string" ) {
4886 ret = jQuery.filter( selector, ret );
4889 ret = this.length > 1 ? jQuery.unique( ret ) : ret;
4891 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
4892 ret = ret.reverse();
4895 return this.pushStack( ret, name, slice.call(arguments).join(",") );
4899 jQuery.fn[ "parentsUntil" ] = function( until, selector ) {
4900 /// <summary>
4901 /// Get the ancestors of each element in the current set of matched elements, up to but not
4902 /// including the element matched by the selector.
4903 /// </summary>
4904 /// <param name="until" type="String">
4905 /// A string containing a selector expression to indicate where to stop matching ancestor
4906 /// elements.
4907 /// </param>
4908 /// <returns type="jQuery" />
4910 var fn = function( elem, i, until ) {
4911 return jQuery.dir( elem, "parentNode", until );
4914 var ret = jQuery.map( this, fn, until );
4916 if ( !runtil.test( "parentsUntil" ) ) {
4917 selector = until;
4920 if ( selector && typeof selector === "string" ) {
4921 ret = jQuery.filter( selector, ret );
4924 ret = this.length > 1 ? jQuery.unique( ret ) : ret;
4926 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( "parentsUntil" ) ) {
4927 ret = ret.reverse();
4930 return this.pushStack( ret, "parentsUntil", slice.call(arguments).join(",") );
4933 jQuery.fn[ "nextUntil" ] = function( until, selector ) {
4934 /// <summary>
4935 /// Get all following siblings of each element up to but not including the element matched
4936 /// by the selector.
4937 /// </summary>
4938 /// <param name="until" type="String">
4939 /// A string containing a selector expression to indicate where to stop matching following
4940 /// sibling elements.
4941 /// </param>
4942 /// <returns type="jQuery" />
4944 var fn = function( elem, i, until ) {
4945 return jQuery.dir( elem, "nextSibling", until );
4948 var ret = jQuery.map( this, fn, until );
4950 if ( !runtil.test( "nextUntil" ) ) {
4951 selector = until;
4954 if ( selector && typeof selector === "string" ) {
4955 ret = jQuery.filter( selector, ret );
4958 ret = this.length > 1 ? jQuery.unique( ret ) : ret;
4960 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( "nextUntil" ) ) {
4961 ret = ret.reverse();
4964 return this.pushStack( ret, "nextUntil", slice.call(arguments).join(",") );
4967 jQuery.fn[ "prevUntil" ] = function( until, selector ) {
4968 /// <summary>
4969 /// Get all preceding siblings of each element up to but not including the element matched
4970 /// by the selector.
4971 /// </summary>
4972 /// <param name="until" type="String">
4973 /// A string containing a selector expression to indicate where to stop matching preceding
4974 /// sibling elements.
4975 /// </param>
4976 /// <returns type="jQuery" />
4978 var fn = function( elem, i, until ) {
4979 return jQuery.dir( elem, "previousSibling", until );
4982 var ret = jQuery.map( this, fn, until );
4984 if ( !runtil.test( "prevUntil" ) ) {
4985 selector = until;
4988 if ( selector && typeof selector === "string" ) {
4989 ret = jQuery.filter( selector, ret );
4992 ret = this.length > 1 ? jQuery.unique( ret ) : ret;
4994 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( "prevUntil" ) ) {
4995 ret = ret.reverse();
4998 return this.pushStack( ret, "prevUntil", slice.call(arguments).join(",") );
5001 jQuery.extend({
5002 filter: function( expr, elems, not ) {
5003 if ( not ) {
5004 expr = ":not(" + expr + ")";
5007 return jQuery.find.matches(expr, elems);
5010 dir: function( elem, dir, until ) {
5011 /// <summary>
5012 /// This member is internal only.
5013 /// </summary>
5014 /// <private />
5016 var matched = [], cur = elem[dir];
5017 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5018 if ( cur.nodeType === 1 ) {
5019 matched.push( cur );
5021 cur = cur[dir];
5023 return matched;
5026 nth: function( cur, result, dir, elem ) {
5027 /// <summary>
5028 /// This member is internal only.
5029 /// </summary>
5030 /// <private />
5032 result = result || 1;
5033 var num = 0;
5035 for ( ; cur; cur = cur[dir] ) {
5036 if ( cur.nodeType === 1 && ++num === result ) {
5037 break;
5041 return cur;
5044 sibling: function( n, elem ) {
5045 /// <summary>
5046 /// This member is internal only.
5047 /// </summary>
5048 /// <private />
5050 var r = [];
5052 for ( ; n; n = n.nextSibling ) {
5053 if ( n.nodeType === 1 && n !== elem ) {
5054 r.push( n );
5058 return r;
5061 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5062 rleadingWhitespace = /^\s+/,
5063 rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
5064 rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
5065 rtagName = /<([\w:]+)/,
5066 rtbody = /<tbody/i,
5067 rhtml = /<|&\w+;/,
5068 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
5069 fcloseTag = function( all, front, tag ) {
5070 return rselfClosing.test( tag ) ?
5071 all :
5072 front + "></" + tag + ">";
5074 wrapMap = {
5075 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5076 legend: [ 1, "<fieldset>", "</fieldset>" ],
5077 thead: [ 1, "<table>", "</table>" ],
5078 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5079 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5080 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5081 area: [ 1, "<map>", "</map>" ],
5082 _default: [ 0, "", "" ]
5085 wrapMap.optgroup = wrapMap.option;
5086 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5087 wrapMap.th = wrapMap.td;
5089 // IE can't serialize <link> and <script> tags normally
5090 if ( !jQuery.support.htmlSerialize ) {
5091 wrapMap._default = [ 1, "div<div>", "</div>" ];
5094 jQuery.fn.extend({
5095 text: function( text ) {
5096 /// <summary>
5097 /// Set the text contents of all matched elements.
5098 /// Similar to html(), but escapes HTML (replace &quot;&lt;&quot; and &quot;&gt;&quot; with their
5099 /// HTML entities).
5100 /// Part of DOM/Attributes
5101 /// </summary>
5102 /// <returns type="jQuery" />
5103 /// <param name="text" type="String">
5104 /// The text value to set the contents of the element to.
5105 /// </param>
5107 if ( jQuery.isFunction(text) ) {
5108 return this.each(function(i) {
5109 var self = jQuery(this);
5110 self.text( text.call(this, i, self.text()) );
5114 if ( typeof text !== "object" && text !== undefined ) {
5115 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5118 return jQuery.getText( this );
5121 wrapAll: function( html ) {
5122 /// <summary>
5123 /// Wrap all matched elements with a structure of other elements.
5124 /// This wrapping process is most useful for injecting additional
5125 /// stucture into a document, without ruining the original semantic
5126 /// qualities of a document.
5127 /// This works by going through the first element
5128 /// provided and finding the deepest ancestor element within its
5129 /// structure - it is that element that will en-wrap everything else.
5130 /// This does not work with elements that contain text. Any necessary text
5131 /// must be added after the wrapping is done.
5132 /// Part of DOM/Manipulation
5133 /// </summary>
5134 /// <returns type="jQuery" />
5135 /// <param name="html" type="Element">
5136 /// A DOM element that will be wrapped around the target.
5137 /// </param>
5139 if ( jQuery.isFunction( html ) ) {
5140 return this.each(function(i) {
5141 jQuery(this).wrapAll( html.call(this, i) );
5145 if ( this[0] ) {
5146 // The elements to wrap the target around
5147 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5149 if ( this[0].parentNode ) {
5150 wrap.insertBefore( this[0] );
5153 wrap.map(function() {
5154 var elem = this;
5156 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5157 elem = elem.firstChild;
5160 return elem;
5161 }).append(this);
5164 return this;
5167 wrapInner: function( html ) {
5168 /// <summary>
5169 /// Wraps the inner child contents of each matched elemenht (including text nodes) with an HTML structure.
5170 /// </summary>
5171 /// <param name="html" type="String">
5172 /// A string of HTML or a DOM element that will be wrapped around the target contents.
5173 /// </param>
5174 /// <returns type="jQuery" />
5176 if ( jQuery.isFunction( html ) ) {
5177 return this.each(function(i) {
5178 jQuery(this).wrapInner( html.call(this, i) );
5182 return this.each(function() {
5183 var self = jQuery( this ), contents = self.contents();
5185 if ( contents.length ) {
5186 contents.wrapAll( html );
5188 } else {
5189 self.append( html );
5194 wrap: function( html ) {
5195 /// <summary>
5196 /// Wrap all matched elements with a structure of other elements.
5197 /// This wrapping process is most useful for injecting additional
5198 /// stucture into a document, without ruining the original semantic
5199 /// qualities of a document.
5200 /// This works by going through the first element
5201 /// provided and finding the deepest ancestor element within its
5202 /// structure - it is that element that will en-wrap everything else.
5203 /// This does not work with elements that contain text. Any necessary text
5204 /// must be added after the wrapping is done.
5205 /// Part of DOM/Manipulation
5206 /// </summary>
5207 /// <returns type="jQuery" />
5208 /// <param name="html" type="Element">
5209 /// A DOM element that will be wrapped around the target.
5210 /// </param>
5212 return this.each(function() {
5213 jQuery( this ).wrapAll( html );
5217 unwrap: function() {
5218 /// <summary>
5219 /// Remove the parents of the set of matched elements from the DOM, leaving the matched
5220 /// elements in their place.
5221 /// </summary>
5222 /// <returns type="jQuery" />
5223 return this.parent().each(function() {
5224 if ( !jQuery.nodeName( this, "body" ) ) {
5225 jQuery( this ).replaceWith( this.childNodes );
5227 }).end();
5230 append: function() {
5231 /// <summary>
5232 /// Append content to the inside of every matched element.
5233 /// This operation is similar to doing an appendChild to all the
5234 /// specified elements, adding them into the document.
5235 /// Part of DOM/Manipulation
5236 /// </summary>
5237 /// <returns type="jQuery" />
5239 return this.domManip(arguments, true, function( elem ) {
5240 if ( this.nodeType === 1 ) {
5241 this.appendChild( elem );
5246 prepend: function() {
5247 /// <summary>
5248 /// Prepend content to the inside of every matched element.
5249 /// This operation is the best way to insert elements
5250 /// inside, at the beginning, of all matched elements.
5251 /// Part of DOM/Manipulation
5252 /// </summary>
5253 /// <returns type="jQuery" />
5255 return this.domManip(arguments, true, function( elem ) {
5256 if ( this.nodeType === 1 ) {
5257 this.insertBefore( elem, this.firstChild );
5262 before: function() {
5263 /// <summary>
5264 /// Insert content before each of the matched elements.
5265 /// Part of DOM/Manipulation
5266 /// </summary>
5267 /// <returns type="jQuery" />
5269 if ( this[0] && this[0].parentNode ) {
5270 return this.domManip(arguments, false, function( elem ) {
5271 this.parentNode.insertBefore( elem, this );
5273 } else if ( arguments.length ) {
5274 var set = jQuery(arguments[0]);
5275 set.push.apply( set, this.toArray() );
5276 return this.pushStack( set, "before", arguments );
5280 after: function() {
5281 /// <summary>
5282 /// Insert content after each of the matched elements.
5283 /// Part of DOM/Manipulation
5284 /// </summary>
5285 /// <returns type="jQuery" />
5287 if ( this[0] && this[0].parentNode ) {
5288 return this.domManip(arguments, false, function( elem ) {
5289 this.parentNode.insertBefore( elem, this.nextSibling );
5291 } else if ( arguments.length ) {
5292 var set = this.pushStack( this, "after", arguments );
5293 set.push.apply( set, jQuery(arguments[0]).toArray() );
5294 return set;
5298 clone: function( events ) {
5299 /// <summary>
5300 /// Clone matched DOM Elements and select the clones.
5301 /// This is useful for moving copies of the elements to another
5302 /// location in the DOM.
5303 /// Part of DOM/Manipulation
5304 /// </summary>
5305 /// <returns type="jQuery" />
5306 /// <param name="deep" type="Boolean" optional="true">
5307 /// (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself.
5308 /// </param>
5310 // Do the clone
5311 var ret = this.map(function() {
5312 if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
5313 // IE copies events bound via attachEvent when
5314 // using cloneNode. Calling detachEvent on the
5315 // clone will also remove the events from the orignal
5316 // In order to get around this, we use innerHTML.
5317 // Unfortunately, this means some modifications to
5318 // attributes in IE that are actually only stored
5319 // as properties will not be copied (such as the
5320 // the name attribute on an input).
5321 var html = this.outerHTML, ownerDocument = this.ownerDocument;
5322 if ( !html ) {
5323 var div = ownerDocument.createElement("div");
5324 div.appendChild( this.cloneNode(true) );
5325 html = div.innerHTML;
5328 return jQuery.clean([html.replace(rinlinejQuery, "")
5329 .replace(rleadingWhitespace, "")], ownerDocument)[0];
5330 } else {
5331 return this.cloneNode(true);
5335 // Copy the events from the original to the clone
5336 if ( events === true ) {
5337 cloneCopyEvent( this, ret );
5338 cloneCopyEvent( this.find("*"), ret.find("*") );
5341 // Return the cloned set
5342 return ret;
5345 html: function( value ) {
5346 /// <summary>
5347 /// Set the html contents of every matched element.
5348 /// This property is not available on XML documents.
5349 /// Part of DOM/Attributes
5350 /// </summary>
5351 /// <returns type="jQuery" />
5352 /// <param name="value" type="String">
5353 /// A string of HTML to set as the content of each matched element.
5354 /// </param>
5356 if ( value === undefined ) {
5357 return this[0] && this[0].nodeType === 1 ?
5358 this[0].innerHTML.replace(rinlinejQuery, "") :
5359 null;
5361 // See if we can take a shortcut and just use innerHTML
5362 } else if ( typeof value === "string" && !/<script/i.test( value ) &&
5363 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5364 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5366 value = value.replace(rxhtmlTag, fcloseTag);
5368 try {
5369 for ( var i = 0, l = this.length; i < l; i++ ) {
5370 // Remove element nodes and prevent memory leaks
5371 if ( this[i].nodeType === 1 ) {
5372 jQuery.cleanData( this[i].getElementsByTagName("*") );
5373 this[i].innerHTML = value;
5377 // If using innerHTML throws an exception, use the fallback method
5378 } catch(e) {
5379 this.empty().append( value );
5382 } else if ( jQuery.isFunction( value ) ) {
5383 this.each(function(i){
5384 var self = jQuery(this), old = self.html();
5385 self.empty().append(function(){
5386 return value.call( this, i, old );
5390 } else {
5391 this.empty().append( value );
5394 return this;
5397 replaceWith: function( value ) {
5398 /// <summary>
5399 /// Replaces all matched element with the specified HTML or DOM elements.
5400 /// </summary>
5401 /// <param name="value" type="Object">
5402 /// The content to insert. May be an HTML string, DOM element, or jQuery object.
5403 /// </param>
5404 /// <returns type="jQuery">The element that was just replaced.</returns>
5406 if ( this[0] && this[0].parentNode ) {
5407 // Make sure that the elements are removed from the DOM before they are inserted
5408 // this can help fix replacing a parent with child elements
5409 if ( !jQuery.isFunction( value ) ) {
5410 value = jQuery( value ).detach();
5412 } else {
5413 return this.each(function(i) {
5414 var self = jQuery(this), old = self.html();
5415 self.replaceWith( value.call( this, i, old ) );
5419 return this.each(function() {
5420 var next = this.nextSibling, parent = this.parentNode;
5422 jQuery(this).remove();
5424 if ( next ) {
5425 jQuery(next).before( value );
5426 } else {
5427 jQuery(parent).append( value );
5430 } else {
5431 return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
5435 detach: function( selector ) {
5436 /// <summary>
5437 /// Remove the set of matched elements from the DOM.
5438 /// </summary>
5439 /// <param name="selector" type="String">
5440 /// A selector expression that filters the set of matched elements to be removed.
5441 /// </param>
5442 /// <returns type="jQuery" />
5444 return this.remove( selector, true );
5447 domManip: function( args, table, callback ) {
5448 /// <param name="args" type="Array">
5449 /// Args
5450 /// </param>
5451 /// <param name="table" type="Boolean">
5452 /// Insert TBODY in TABLEs if one is not found.
5453 /// </param>
5454 /// <param name="dir" type="Number">
5455 /// If dir&lt;0, process args in reverse order.
5456 /// </param>
5457 /// <param name="fn" type="Function">
5458 /// The function doing the DOM manipulation.
5459 /// </param>
5460 /// <returns type="jQuery" />
5461 /// <summary>
5462 /// Part of Core
5463 /// </summary>
5465 var results, first, value = args[0], scripts = [];
5467 // We can't cloneNode fragments that contain checked, in WebKit
5468 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5469 return this.each(function() {
5470 jQuery(this).domManip( args, table, callback, true );
5474 if ( jQuery.isFunction(value) ) {
5475 return this.each(function(i) {
5476 var self = jQuery(this);
5477 args[0] = value.call(this, i, table ? self.html() : undefined);
5478 self.domManip( args, table, callback );
5482 if ( this[0] ) {
5483 // If we're in a fragment, just use that instead of building a new one
5484 if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
5485 results = { fragment: args[0].parentNode };
5486 } else {
5487 results = buildFragment( args, this, scripts );
5490 first = results.fragment.firstChild;
5492 if ( first ) {
5493 table = table && jQuery.nodeName( first, "tr" );
5495 for ( var i = 0, l = this.length; i < l; i++ ) {
5496 callback.call(
5497 table ?
5498 root(this[i], first) :
5499 this[i],
5500 results.cacheable || this.length > 1 || i > 0 ?
5501 results.fragment.cloneNode(true) :
5502 results.fragment
5507 if ( scripts ) {
5508 jQuery.each( scripts, evalScript );
5512 return this;
5514 function root( elem, cur ) {
5515 return jQuery.nodeName(elem, "table") ?
5516 (elem.getElementsByTagName("tbody")[0] ||
5517 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
5518 elem;
5523 function cloneCopyEvent(orig, ret) {
5524 var i = 0;
5526 ret.each(function() {
5527 if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
5528 return;
5531 var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
5533 if ( events ) {
5534 delete curData.handle;
5535 curData.events = {};
5537 for ( var type in events ) {
5538 for ( var handler in events[ type ] ) {
5539 jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
5546 function buildFragment( args, nodes, scripts ) {
5547 var fragment, cacheable, cacheresults, doc;
5549 // webkit does not clone 'checked' attribute of radio inputs on cloneNode, so don't cache if string has a checked
5550 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
5551 cacheable = true;
5552 cacheresults = jQuery.fragments[ args[0] ];
5553 if ( cacheresults ) {
5554 if ( cacheresults !== 1 ) {
5555 fragment = cacheresults;
5560 if ( !fragment ) {
5561 doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
5562 fragment = doc.createDocumentFragment();
5563 jQuery.clean( args, doc, fragment, scripts );
5566 if ( cacheable ) {
5567 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
5570 return { fragment: fragment, cacheable: cacheable };
5573 jQuery.fragments = {};
5575 // jQuery.each({
5576 // appendTo: "append",
5577 // prependTo: "prepend",
5578 // insertBefore: "before",
5579 // insertAfter: "after",
5580 // replaceAll: "replaceWith"
5581 // }, function( name, original ) {
5582 // jQuery.fn[ name ] = function( selector ) {
5583 // var ret = [], insert = jQuery( selector );
5585 // for ( var i = 0, l = insert.length; i < l; i++ ) {
5586 // var elems = (i > 0 ? this.clone(true) : this).get();
5587 // jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
5588 // ret = ret.concat( elems );
5589 // }
5590 // return this.pushStack( ret, name, insert.selector );
5591 // };
5592 // });
5594 jQuery.fn[ "appendTo" ] = function( selector ) {
5595 /// <summary>
5596 /// Append all of the matched elements to another, specified, set of elements.
5597 /// As of jQuery 1.3.2, returns all of the inserted elements.
5598 /// This operation is, essentially, the reverse of doing a regular
5599 /// $(A).append(B), in that instead of appending B to A, you're appending
5600 /// A to B.
5601 /// </summary>
5602 /// <param name="selector" type="Selector">
5603 /// target to which the content will be appended.
5604 /// </param>
5605 /// <returns type="jQuery" />
5607 var ret = [], insert = jQuery( selector );
5609 for ( var i = 0, l = insert.length; i < l; i++ ) {
5610 var elems = (i > 0 ? this.clone(true) : this).get();
5611 jQuery.fn[ "append" ].apply( jQuery(insert[i]), elems );
5612 ret = ret.concat( elems );
5614 return this.pushStack( ret, "appendTo", insert.selector );
5617 jQuery.fn[ "prependTo" ] = function( selector ) {
5618 /// <summary>
5619 /// Prepend all of the matched elements to another, specified, set of elements.
5620 /// As of jQuery 1.3.2, returns all of the inserted elements.
5621 /// This operation is, essentially, the reverse of doing a regular
5622 /// $(A).prepend(B), in that instead of prepending B to A, you're prepending
5623 /// A to B.
5624 /// </summary>
5625 /// <param name="selector" type="Selector">
5626 /// target to which the content will be appended.
5627 /// </param>
5628 /// <returns type="jQuery" />
5630 var ret = [], insert = jQuery( selector );
5632 for ( var i = 0, l = insert.length; i < l; i++ ) {
5633 var elems = (i > 0 ? this.clone(true) : this).get();
5634 jQuery.fn[ "prepend" ].apply( jQuery(insert[i]), elems );
5635 ret = ret.concat( elems );
5637 return this.pushStack( ret, "prependTo", insert.selector );
5640 jQuery.fn[ "insertBefore" ] = function( selector ) {
5641 /// <summary>
5642 /// Insert all of the matched elements before another, specified, set of elements.
5643 /// As of jQuery 1.3.2, returns all of the inserted elements.
5644 /// This operation is, essentially, the reverse of doing a regular
5645 /// $(A).before(B), in that instead of inserting B before A, you're inserting
5646 /// A before B.
5647 /// </summary>
5648 /// <param name="content" type="String">
5649 /// Content after which the selected element(s) is inserted.
5650 /// </param>
5651 /// <returns type="jQuery" />
5653 var ret = [], insert = jQuery( selector );
5655 for ( var i = 0, l = insert.length; i < l; i++ ) {
5656 var elems = (i > 0 ? this.clone(true) : this).get();
5657 jQuery.fn[ "before" ].apply( jQuery(insert[i]), elems );
5658 ret = ret.concat( elems );
5660 return this.pushStack( ret, "insertBefore", insert.selector );
5663 jQuery.fn[ "insertAfter" ] = function( selector ) {
5664 /// <summary>
5665 /// Insert all of the matched elements after another, specified, set of elements.
5666 /// As of jQuery 1.3.2, returns all of the inserted elements.
5667 /// This operation is, essentially, the reverse of doing a regular
5668 /// $(A).after(B), in that instead of inserting B after A, you're inserting
5669 /// A after B.
5670 /// </summary>
5671 /// <param name="content" type="String">
5672 /// Content after which the selected element(s) is inserted.
5673 /// </param>
5674 /// <returns type="jQuery" />
5676 var ret = [], insert = jQuery( selector );
5678 for ( var i = 0, l = insert.length; i < l; i++ ) {
5679 var elems = (i > 0 ? this.clone(true) : this).get();
5680 jQuery.fn[ "after" ].apply( jQuery(insert[i]), elems );
5681 ret = ret.concat( elems );
5683 return this.pushStack( ret, "insertAfter", insert.selector );
5686 jQuery.fn[ "replaceAll" ] = function( selector ) {
5687 /// <summary>
5688 /// Replaces the elements matched by the specified selector with the matched elements.
5689 /// As of jQuery 1.3.2, returns all of the inserted elements.
5690 /// </summary>
5691 /// <param name="selector" type="Selector">The elements to find and replace the matched elements with.</param>
5692 /// <returns type="jQuery" />
5694 var ret = [], insert = jQuery( selector );
5696 for ( var i = 0, l = insert.length; i < l; i++ ) {
5697 var elems = (i > 0 ? this.clone(true) : this).get();
5698 jQuery.fn[ "replaceWith" ].apply( jQuery(insert[i]), elems );
5699 ret = ret.concat( elems );
5701 return this.pushStack( ret, "replaceAll", insert.selector );
5704 jQuery.each({
5705 // keepData is for internal use only--do not document
5706 remove: function( selector, keepData ) {
5707 if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
5708 if ( !keepData && this.nodeType === 1 ) {
5709 jQuery.cleanData( this.getElementsByTagName("*") );
5710 jQuery.cleanData( [ this ] );
5713 if ( this.parentNode ) {
5714 this.parentNode.removeChild( this );
5719 empty: function() {
5720 /// <summary>
5721 /// Removes all child nodes from the set of matched elements.
5722 /// Part of DOM/Manipulation
5723 /// </summary>
5724 /// <returns type="jQuery" />
5726 // Remove element nodes and prevent memory leaks
5727 if ( this.nodeType === 1 ) {
5728 jQuery.cleanData( this.getElementsByTagName("*") );
5731 // Remove any remaining nodes
5732 while ( this.firstChild ) {
5733 this.removeChild( this.firstChild );
5736 }, function( name, fn ) {
5737 jQuery.fn[ name ] = function() {
5738 return this.each( fn, arguments );
5742 jQuery.extend({
5743 clean: function( elems, context, fragment, scripts ) {
5744 /// <summary>
5745 /// This method is internal only.
5746 /// </summary>
5747 /// <private />
5749 context = context || document;
5751 // !context.createElement fails in IE with an error but returns typeof 'object'
5752 if ( typeof context.createElement === "undefined" ) {
5753 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
5756 var ret = [];
5758 jQuery.each(elems, function( i, elem ) {
5759 if ( typeof elem === "number" ) {
5760 elem += "";
5763 if ( !elem ) {
5764 return;
5767 // Convert html string into DOM nodes
5768 if ( typeof elem === "string" && !rhtml.test( elem ) ) {
5769 elem = context.createTextNode( elem );
5771 } else if ( typeof elem === "string" ) {
5772 // Fix "XHTML"-style tags in all browsers
5773 elem = elem.replace(rxhtmlTag, fcloseTag);
5775 // Trim whitespace, otherwise indexOf won't work as expected
5776 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
5777 wrap = wrapMap[ tag ] || wrapMap._default,
5778 depth = wrap[0],
5779 div = context.createElement("div");
5781 // Go to html and back, then peel off extra wrappers
5782 div.innerHTML = wrap[1] + elem + wrap[2];
5784 // Move to the right depth
5785 while ( depth-- ) {
5786 div = div.lastChild;
5789 // Remove IE's autoinserted <tbody> from table fragments
5790 if ( !jQuery.support.tbody ) {
5792 // String was a <table>, *may* have spurious <tbody>
5793 var hasBody = rtbody.test(elem),
5794 tbody = tag === "table" && !hasBody ?
5795 div.firstChild && div.firstChild.childNodes :
5797 // String was a bare <thead> or <tfoot>
5798 wrap[1] === "<table>" && !hasBody ?
5799 div.childNodes :
5802 for ( var j = tbody.length - 1; j >= 0 ; --j ) {
5803 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
5804 tbody[ j ].parentNode.removeChild( tbody[ j ] );
5810 // IE completely kills leading whitespace when innerHTML is used
5811 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
5812 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
5815 elem = jQuery.makeArray( div.childNodes );
5818 if ( elem.nodeType ) {
5819 ret.push( elem );
5820 } else {
5821 ret = jQuery.merge( ret, elem );
5826 if ( fragment ) {
5827 for ( var i = 0; ret[i]; i++ ) {
5828 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
5829 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
5830 } else {
5831 if ( ret[i].nodeType === 1 ) {
5832 ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
5834 fragment.appendChild( ret[i] );
5839 return ret;
5842 cleanData: function( elems ) {
5843 for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
5844 jQuery.event.remove( elem );
5845 jQuery.removeData( elem );
5849 // exclude the following css properties to add px
5850 var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
5851 ralpha = /alpha\([^)]*\)/,
5852 ropacity = /opacity=([^)]*)/,
5853 rfloat = /float/i,
5854 rdashAlpha = /-([a-z])/ig,
5855 rupper = /([A-Z])/g,
5856 rnumpx = /^-?\d+(?:px)?$/i,
5857 rnum = /^-?\d/,
5859 cssShow = { position: "absolute", visibility: "hidden", display:"block" },
5860 cssWidth = [ "Left", "Right" ],
5861 cssHeight = [ "Top", "Bottom" ],
5863 // cache check for defaultView.getComputedStyle
5864 getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
5865 // normalize float css property
5866 styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
5867 fcamelCase = function( all, letter ) {
5868 return letter.toUpperCase();
5871 jQuery.fn.css = function( name, value ) {
5872 /// <summary>
5873 /// Set a single style property to a value, on all matched elements.
5874 /// If a number is provided, it is automatically converted into a pixel value.
5875 /// Part of CSS
5876 /// </summary>
5877 /// <returns type="jQuery" />
5878 /// <param name="name" type="String">
5879 /// A CSS property name.
5880 /// </param>
5881 /// <param name="value" type="String">
5882 /// A value to set for the property.
5883 /// </param>
5885 return access( this, name, value, true, function( elem, name, value ) {
5886 if ( value === undefined ) {
5887 return jQuery.curCSS( elem, name );
5890 if ( typeof value === "number" && !rexclude.test(name) ) {
5891 value += "px";
5894 jQuery.style( elem, name, value );
5898 jQuery.extend({
5899 style: function( elem, name, value ) {
5900 // don't set styles on text and comment nodes
5901 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
5902 return undefined;
5905 // ignore negative width and height values #1599
5906 if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
5907 value = undefined;
5910 var style = elem.style || elem, set = value !== undefined;
5912 // IE uses filters for opacity
5913 if ( !jQuery.support.opacity && name === "opacity" ) {
5914 if ( set ) {
5915 // IE has trouble with opacity if it does not have layout
5916 // Force it by setting the zoom level
5917 style.zoom = 1;
5919 // Set the alpha filter to set the opacity
5920 var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
5921 var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
5922 style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
5925 return style.filter && style.filter.indexOf("opacity=") >= 0 ?
5926 (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
5930 // Make sure we're using the right name for getting the float value
5931 if ( rfloat.test( name ) ) {
5932 name = styleFloat;
5935 name = name.replace(rdashAlpha, fcamelCase);
5937 if ( set ) {
5938 style[ name ] = value;
5941 return style[ name ];
5944 css: function( elem, name, force, extra ) {
5945 /// <summary>
5946 /// This method is internal only.
5947 /// </summary>
5948 /// <private />
5950 if ( name === "width" || name === "height" ) {
5951 var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
5953 function getWH() {
5954 val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
5956 if ( extra === "border" ) {
5957 return;
5960 jQuery.each( which, function() {
5961 if ( !extra ) {
5962 val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
5965 if ( extra === "margin" ) {
5966 val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
5967 } else {
5968 val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
5973 if ( elem.offsetWidth !== 0 ) {
5974 getWH();
5975 } else {
5976 jQuery.swap( elem, props, getWH );
5979 return Math.max(0, Math.round(val));
5982 return jQuery.curCSS( elem, name, force );
5985 curCSS: function( elem, name, force ) {
5986 /// <summary>
5987 /// This method is internal only.
5988 /// </summary>
5989 /// <private />
5991 var ret, style = elem.style, filter;
5993 // IE uses filters for opacity
5994 if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
5995 ret = ropacity.test(elem.currentStyle.filter || "") ?
5996 (parseFloat(RegExp.$1) / 100) + "" :
5999 return ret === "" ?
6000 "1" :
6001 ret;
6004 // Make sure we're using the right name for getting the float value
6005 if ( rfloat.test( name ) ) {
6006 name = styleFloat;
6009 if ( !force && style && style[ name ] ) {
6010 ret = style[ name ];
6012 } else if ( getComputedStyle ) {
6014 // Only "float" is needed here
6015 if ( rfloat.test( name ) ) {
6016 name = "float";
6019 name = name.replace( rupper, "-$1" ).toLowerCase();
6021 var defaultView = elem.ownerDocument.defaultView;
6023 if ( !defaultView ) {
6024 return null;
6027 var computedStyle = defaultView.getComputedStyle( elem, null );
6029 if ( computedStyle ) {
6030 ret = computedStyle.getPropertyValue( name );
6033 // We should always get a number back from opacity
6034 if ( name === "opacity" && ret === "" ) {
6035 ret = "1";
6038 } else if ( elem.currentStyle ) {
6039 var camelCase = name.replace(rdashAlpha, fcamelCase);
6041 ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
6043 // From the awesome hack by Dean Edwards
6044 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6046 // If we're not dealing with a regular pixel number
6047 // but a number that has a weird ending, we need to convert it to pixels
6048 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6049 // Remember the original values
6050 var left = style.left, rsLeft = elem.runtimeStyle.left;
6052 // Put in the new values to get a computed value out
6053 elem.runtimeStyle.left = elem.currentStyle.left;
6054 style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
6055 ret = style.pixelLeft + "px";
6057 // Revert the changed values
6058 style.left = left;
6059 elem.runtimeStyle.left = rsLeft;
6063 return ret;
6066 // A method for quickly swapping in/out CSS properties to get correct calculations
6067 swap: function( elem, options, callback ) {
6068 /// <summary>
6069 /// Swap in/out style options.
6070 /// </summary>
6072 var old = {};
6074 // Remember the old values, and insert the new ones
6075 for ( var name in options ) {
6076 old[ name ] = elem.style[ name ];
6077 elem.style[ name ] = options[ name ];
6080 callback.call( elem );
6082 // Revert the old values
6083 for ( var name in options ) {
6084 elem.style[ name ] = old[ name ];
6089 if ( jQuery.expr && jQuery.expr.filters ) {
6090 jQuery.expr.filters.hidden = function( elem ) {
6091 var width = elem.offsetWidth, height = elem.offsetHeight,
6092 skip = elem.nodeName.toLowerCase() === "tr";
6094 return width === 0 && height === 0 && !skip ?
6095 true :
6096 width > 0 && height > 0 && !skip ?
6097 false :
6098 jQuery.curCSS(elem, "display") === "none";
6101 jQuery.expr.filters.visible = function( elem ) {
6102 return !jQuery.expr.filters.hidden( elem );
6105 var jsc = now(),
6106 rscript = /<script(.|\s)*?\/script>/gi,
6107 rselectTextarea = /select|textarea/i,
6108 rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
6109 jsre = /=\?(&|$)/,
6110 rquery = /\?/,
6111 rts = /(\?|&)_=.*?(&|$)/,
6112 rurl = /^(\w+:)?\/\/([^\/?#]+)/,
6113 r20 = /%20/g;
6115 jQuery.fn.extend({
6116 // Keep a copy of the old load
6117 _load: jQuery.fn.load,
6119 load: function( url, params, callback ) {
6120 /// <summary>
6121 /// Loads HTML from a remote file and injects it into the DOM. By default performs a GET request, but if parameters are included
6122 /// then a POST will be performed.
6123 /// </summary>
6124 /// <param name="url" type="String">The URL of the HTML page to load.</param>
6125 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
6126 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus, XMLHttpRequest) such that this maps the injected DOM element.</param>
6127 /// <returns type="jQuery" />
6129 if ( typeof url !== "string" ) {
6130 return this._load( url );
6132 // Don't do a request if no elements are being requested
6133 } else if ( !this.length ) {
6134 return this;
6137 var off = url.indexOf(" ");
6138 if ( off >= 0 ) {
6139 var selector = url.slice(off, url.length);
6140 url = url.slice(0, off);
6143 // Default to a GET request
6144 var type = "GET";
6146 // If the second parameter was provided
6147 if ( params ) {
6148 // If it's a function
6149 if ( jQuery.isFunction( params ) ) {
6150 // We assume that it's the callback
6151 callback = params;
6152 params = null;
6154 // Otherwise, build a param string
6155 } else if ( typeof params === "object" ) {
6156 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
6157 type = "POST";
6161 var self = this;
6163 // Request the remote document
6164 jQuery.ajax({
6165 url: url,
6166 type: type,
6167 dataType: "html",
6168 data: params,
6169 complete: function( res, status ) {
6170 // If successful, inject the HTML into all the matched elements
6171 if ( status === "success" || status === "notmodified" ) {
6172 // See if a selector was specified
6173 self.html( selector ?
6174 // Create a dummy div to hold the results
6175 jQuery("<div />")
6176 // inject the contents of the document in, removing the scripts
6177 // to avoid any 'Permission Denied' errors in IE
6178 .append(res.responseText.replace(rscript, ""))
6180 // Locate the specified elements
6181 .find(selector) :
6183 // If not, just inject the full result
6184 res.responseText );
6187 if ( callback ) {
6188 self.each( callback, [res.responseText, status, res] );
6193 return this;
6196 serialize: function() {
6197 /// <summary>
6198 /// Serializes a set of input elements into a string of data.
6199 /// </summary>
6200 /// <returns type="String">The serialized result</returns>
6202 return jQuery.param(this.serializeArray());
6204 serializeArray: function() {
6205 /// <summary>
6206 /// Serializes all forms and form elements but returns a JSON data structure.
6207 /// </summary>
6208 /// <returns type="String">A JSON data structure representing the serialized items.</returns>
6210 return this.map(function() {
6211 return this.elements ? jQuery.makeArray(this.elements) : this;
6213 .filter(function() {
6214 return this.name && !this.disabled &&
6215 (this.checked || rselectTextarea.test(this.nodeName) ||
6216 rinput.test(this.type));
6218 .map(function( i, elem ) {
6219 var val = jQuery(this).val();
6221 return val == null ?
6222 null :
6223 jQuery.isArray(val) ?
6224 jQuery.map( val, function( val, i ) {
6225 return { name: elem.name, value: val };
6226 }) :
6227 { name: elem.name, value: val };
6228 }).get();
6232 // Attach a bunch of functions for handling common AJAX events
6233 // jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
6234 // jQuery.fn[o] = function( f ) {
6235 // return this.bind(o, f);
6236 // };
6237 // });
6239 jQuery.fn["ajaxStart"] = function( f ) {
6240 /// <summary>
6241 /// Attach a function to be executed whenever an AJAX request begins and there is none already active. This is an Ajax Event.
6242 /// </summary>
6243 /// <param name="f" type="Function">The function to execute.</param>
6244 /// <returns type="jQuery" />
6246 return this.bind("ajaxStart", f);
6249 jQuery.fn["ajaxStop"] = function( f ) {
6250 /// <summary>
6251 /// Attach a function to be executed whenever all AJAX requests have ended. This is an Ajax Event.
6252 /// </summary>
6253 /// <param name="f" type="Function">The function to execute.</param>
6254 /// <returns type="jQuery" />
6256 return this.bind("ajaxStop", f);
6259 jQuery.fn["ajaxComplete"] = function( f ) {
6260 /// <summary>
6261 /// Attach a function to be executed whenever an AJAX request completes. This is an Ajax Event.
6262 /// </summary>
6263 /// <param name="f" type="Function">The function to execute.</param>
6264 /// <returns type="jQuery" />
6266 return this.bind("ajaxComplete", f);
6269 jQuery.fn["ajaxError"] = function( f ) {
6270 /// <summary>
6271 /// Attach a function to be executed whenever an AJAX request fails. This is an Ajax Event.
6272 /// </summary>
6273 /// <param name="f" type="Function">The function to execute.</param>
6274 /// <returns type="jQuery" />
6276 return this.bind("ajaxError", f);
6279 jQuery.fn["ajaxSuccess"] = function( f ) {
6280 /// <summary>
6281 /// Attach a function to be executed whenever an AJAX request completes successfully. This is an Ajax Event.
6282 /// </summary>
6283 /// <param name="f" type="Function">The function to execute.</param>
6284 /// <returns type="jQuery" />
6286 return this.bind("ajaxSuccess", f);
6289 jQuery.fn["ajaxSend"] = function( f ) {
6290 /// <summary>
6291 /// Attach a function to be executed before an AJAX request is sent. This is an Ajax Event.
6292 /// </summary>
6293 /// <param name="f" type="Function">The function to execute.</param>
6294 /// <returns type="jQuery" />
6296 return this.bind("ajaxSend", f);
6299 jQuery.extend({
6301 get: function( url, data, callback, type ) {
6302 /// <summary>
6303 /// Loads a remote page using an HTTP GET request.
6304 /// </summary>
6305 /// <param name="url" type="String">The URL of the HTML page to load.</param>
6306 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
6307 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus) such that this maps the options for this AJAX request.</param>
6308 /// <param name="type" optional="true" type="String">Type of data to be returned to callback function. Valid valiues are xml, html, script, json, text, _default.</param>
6309 /// <returns type="XMLHttpRequest" />
6311 // shift arguments if data argument was omited
6312 if ( jQuery.isFunction( data ) ) {
6313 type = type || callback;
6314 callback = data;
6315 data = null;
6318 return jQuery.ajax({
6319 type: "GET",
6320 url: url,
6321 data: data,
6322 success: callback,
6323 dataType: type
6327 getScript: function( url, callback ) {
6328 /// <summary>
6329 /// Loads and executes a local JavaScript file using an HTTP GET request.
6330 /// </summary>
6331 /// <param name="url" type="String">The URL of the script to load.</param>
6332 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(data, textStatus) such that this maps the options for the AJAX request.</param>
6333 /// <returns type="XMLHttpRequest" />
6335 return jQuery.get(url, null, callback, "script");
6338 getJSON: function( url, data, callback ) {
6339 /// <summary>
6340 /// Loads JSON data using an HTTP GET request.
6341 /// </summary>
6342 /// <param name="url" type="String">The URL of the JSON data to load.</param>
6343 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
6344 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete if the data is loaded successfully. It should map function(data, textStatus) such that this maps the options for this AJAX request.</param>
6345 /// <returns type="XMLHttpRequest" />
6347 return jQuery.get(url, data, callback, "json");
6350 post: function( url, data, callback, type ) {
6351 /// <summary>
6352 /// Loads a remote page using an HTTP POST request.
6353 /// </summary>
6354 /// <param name="url" type="String">The URL of the HTML page to load.</param>
6355 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
6356 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus) such that this maps the options for this AJAX request.</param>
6357 /// <param name="type" optional="true" type="String">Type of data to be returned to callback function. Valid valiues are xml, html, script, json, text, _default.</param>
6358 /// <returns type="XMLHttpRequest" />
6360 // shift arguments if data argument was omited
6361 if ( jQuery.isFunction( data ) ) {
6362 type = type || callback;
6363 callback = data;
6364 data = {};
6367 return jQuery.ajax({
6368 type: "POST",
6369 url: url,
6370 data: data,
6371 success: callback,
6372 dataType: type
6376 ajaxSetup: function( settings ) {
6377 /// <summary>
6378 /// Sets up global settings for AJAX requests.
6379 /// </summary>
6380 /// <param name="settings" type="Options">A set of key/value pairs that configure the default Ajax request.</param>
6382 jQuery.extend( jQuery.ajaxSettings, settings );
6385 ajaxSettings: {
6386 url: location.href,
6387 global: true,
6388 type: "GET",
6389 contentType: "application/x-www-form-urlencoded",
6390 processData: true,
6391 async: true,
6393 timeout: 0,
6394 data: null,
6395 username: null,
6396 password: null,
6397 traditional: false,
6399 // Create the request object; Microsoft failed to properly
6400 // implement the XMLHttpRequest in IE7 (can't request local files),
6401 // so we use the ActiveXObject when it is available
6402 // This function can be overriden by calling jQuery.ajaxSetup
6403 xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
6404 function() {
6405 return new window.XMLHttpRequest();
6407 function() {
6408 try {
6409 return new window.ActiveXObject("Microsoft.XMLHTTP");
6410 } catch(e) {}
6412 accepts: {
6413 xml: "application/xml, text/xml",
6414 html: "text/html",
6415 script: "text/javascript, application/javascript",
6416 json: "application/json, text/javascript",
6417 text: "text/plain",
6418 _default: "*/*"
6422 // Last-Modified header cache for next request
6423 lastModified: {},
6424 etag: {},
6426 ajax: function( origSettings ) {
6427 /// <summary>
6428 /// Load a remote page using an HTTP request.
6429 /// </summary>
6430 /// <private />
6432 var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
6434 var jsonp, status, data,
6435 callbackContext = origSettings && origSettings.context || s,
6436 type = s.type.toUpperCase();
6438 // convert data if not already a string
6439 if ( s.data && s.processData && typeof s.data !== "string" ) {
6440 s.data = jQuery.param( s.data, s.traditional );
6443 // Handle JSONP Parameter Callbacks
6444 if ( s.dataType === "jsonp" ) {
6445 if ( type === "GET" ) {
6446 if ( !jsre.test( s.url ) ) {
6447 s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
6449 } else if ( !s.data || !jsre.test(s.data) ) {
6450 s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
6452 s.dataType = "json";
6455 // Build temporary JSONP function
6456 if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
6457 jsonp = s.jsonpCallback || ("jsonp" + jsc++);
6459 // Replace the =? sequence both in the query string and the data
6460 if ( s.data ) {
6461 s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
6464 s.url = s.url.replace(jsre, "=" + jsonp + "$1");
6466 // We need to make sure
6467 // that a JSONP style response is executed properly
6468 s.dataType = "script";
6470 // Handle JSONP-style loading
6471 window[ jsonp ] = window[ jsonp ] || function( tmp ) {
6472 data = tmp;
6473 success();
6474 complete();
6475 // Garbage collect
6476 window[ jsonp ] = undefined;
6478 try {
6479 delete window[ jsonp ];
6480 } catch(e) {}
6482 if ( head ) {
6483 head.removeChild( script );
6488 if ( s.dataType === "script" && s.cache === null ) {
6489 s.cache = false;
6492 if ( s.cache === false && type === "GET" ) {
6493 var ts = now();
6495 // try replacing _= if it is there
6496 var ret = s.url.replace(rts, "$1_=" + ts + "$2");
6498 // if nothing was replaced, add timestamp to the end
6499 s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
6502 // If data is available, append data to url for get requests
6503 if ( s.data && type === "GET" ) {
6504 s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
6507 // Watch for a new set of requests
6508 if ( s.global && ! jQuery.active++ ) {
6509 jQuery.event.trigger( "ajaxStart" );
6512 // Matches an absolute URL, and saves the domain
6513 var parts = rurl.exec( s.url ),
6514 remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
6516 // If we're requesting a remote document
6517 // and trying to load JSON or Script with a GET
6518 if ( s.dataType === "script" && type === "GET" && remote ) {
6519 var head = document.getElementsByTagName("head")[0] || document.documentElement;
6520 var script = document.createElement("script");
6521 script.src = s.url;
6522 if ( s.scriptCharset ) {
6523 script.charset = s.scriptCharset;
6526 // Handle Script loading
6527 if ( !jsonp ) {
6528 var done = false;
6530 // Attach handlers for all browsers
6531 script.onload = script.onreadystatechange = function() {
6532 if ( !done && (!this.readyState ||
6533 this.readyState === "loaded" || this.readyState === "complete") ) {
6534 done = true;
6535 success();
6536 complete();
6538 // Handle memory leak in IE
6539 script.onload = script.onreadystatechange = null;
6540 if ( head && script.parentNode ) {
6541 head.removeChild( script );
6547 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
6548 // This arises when a base node is used (#2709 and #4378).
6549 head.insertBefore( script, head.firstChild );
6551 // We handle everything using the script element injection
6552 return undefined;
6555 var requestDone = false;
6557 // Create the request object
6558 var xhr = s.xhr();
6560 if ( !xhr ) {
6561 return;
6564 // Open the socket
6565 // Passing null username, generates a login popup on Opera (#2865)
6566 if ( s.username ) {
6567 xhr.open(type, s.url, s.async, s.username, s.password);
6568 } else {
6569 xhr.open(type, s.url, s.async);
6572 // Need an extra try/catch for cross domain requests in Firefox 3
6573 try {
6574 // Set the correct header, if data is being sent
6575 if ( s.data || origSettings && origSettings.contentType ) {
6576 xhr.setRequestHeader("Content-Type", s.contentType);
6579 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6580 if ( s.ifModified ) {
6581 if ( jQuery.lastModified[s.url] ) {
6582 xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
6585 if ( jQuery.etag[s.url] ) {
6586 xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
6590 // Set header so the called script knows that it's an XMLHttpRequest
6591 // Only send the header if it's not a remote XHR
6592 if ( !remote ) {
6593 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
6596 // Set the Accepts header for the server, depending on the dataType
6597 xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
6598 s.accepts[ s.dataType ] + ", */*" :
6599 s.accepts._default );
6600 } catch(e) {}
6602 // Allow custom headers/mimetypes and early abort
6603 if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
6604 // Handle the global AJAX counter
6605 if ( s.global && ! --jQuery.active ) {
6606 jQuery.event.trigger( "ajaxStop" );
6609 // close opended socket
6610 xhr.abort();
6611 return false;
6614 if ( s.global ) {
6615 trigger("ajaxSend", [xhr, s]);
6618 // Wait for a response to come back
6619 var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
6620 // The request was aborted
6621 if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) {
6622 // Opera doesn't call onreadystatechange before this point
6623 // so we simulate the call
6624 if ( !requestDone ) {
6625 complete();
6628 requestDone = true;
6629 if ( xhr ) {
6630 xhr.onreadystatechange = jQuery.noop;
6633 // The transfer is complete and the data is available, or the request timed out
6634 } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
6635 requestDone = true;
6636 xhr.onreadystatechange = jQuery.noop;
6638 status = isTimeout === "timeout" ?
6639 "timeout" :
6640 !jQuery.httpSuccess( xhr ) ?
6641 "error" :
6642 s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
6643 "notmodified" :
6644 "success";
6646 var errMsg;
6648 if ( status === "success" ) {
6649 // Watch for, and catch, XML document parse errors
6650 try {
6651 // process the data (runs the xml through httpData regardless of callback)
6652 data = jQuery.httpData( xhr, s.dataType, s );
6653 } catch(err) {
6654 status = "parsererror";
6655 errMsg = err;
6659 // Make sure that the request was successful or notmodified
6660 if ( status === "success" || status === "notmodified" ) {
6661 // JSONP handles its own success callback
6662 if ( !jsonp ) {
6663 success();
6665 } else {
6666 jQuery.handleError(s, xhr, status, errMsg);
6669 // Fire the complete handlers
6670 complete();
6672 if ( isTimeout === "timeout" ) {
6673 xhr.abort();
6676 // Stop memory leaks
6677 if ( s.async ) {
6678 xhr = null;
6683 // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
6684 // Opera doesn't fire onreadystatechange at all on abort
6685 try {
6686 var oldAbort = xhr.abort;
6687 xhr.abort = function() {
6688 if ( xhr ) {
6689 oldAbort.call( xhr );
6692 onreadystatechange( "abort" );
6694 } catch(e) { }
6696 // Timeout checker
6697 if ( s.async && s.timeout > 0 ) {
6698 setTimeout(function() {
6699 // Check to see if the request is still happening
6700 if ( xhr && !requestDone ) {
6701 onreadystatechange( "timeout" );
6703 }, s.timeout);
6706 // Send the data
6707 try {
6708 xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
6709 } catch(e) {
6710 jQuery.handleError(s, xhr, null, e);
6711 // Fire the complete handlers
6712 complete();
6715 // firefox 1.5 doesn't fire statechange for sync requests
6716 if ( !s.async ) {
6717 onreadystatechange();
6720 function success() {
6721 // If a local callback was specified, fire it and pass it the data
6722 if ( s.success ) {
6723 s.success.call( callbackContext, data, status, xhr );
6726 // Fire the global callback
6727 if ( s.global ) {
6728 trigger( "ajaxSuccess", [xhr, s] );
6732 function complete() {
6733 // Process result
6734 if ( s.complete ) {
6735 s.complete.call( callbackContext, xhr, status);
6738 // The request was completed
6739 if ( s.global ) {
6740 trigger( "ajaxComplete", [xhr, s] );
6743 // Handle the global AJAX counter
6744 if ( s.global && ! --jQuery.active ) {
6745 jQuery.event.trigger( "ajaxStop" );
6749 function trigger(type, args) {
6750 (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
6753 // return XMLHttpRequest to allow aborting the request etc.
6754 return xhr;
6757 handleError: function( s, xhr, status, e ) {
6758 /// <summary>
6759 /// This method is internal.
6760 /// </summary>
6761 /// <private />
6763 // If a local callback was specified, fire it
6764 if ( s.error ) {
6765 s.error.call( s.context || s, xhr, status, e );
6768 // Fire the global callback
6769 if ( s.global ) {
6770 (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
6774 // Counter for holding the number of active queries
6775 active: 0,
6777 // Determines if an XMLHttpRequest was successful or not
6778 httpSuccess: function( xhr ) {
6779 /// <summary>
6780 /// This method is internal.
6781 /// </summary>
6782 /// <private />
6784 try {
6785 // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
6786 return !xhr.status && location.protocol === "file:" ||
6787 // Opera returns 0 when status is 304
6788 ( xhr.status >= 200 && xhr.status < 300 ) ||
6789 xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
6790 } catch(e) {}
6792 return false;
6795 // Determines if an XMLHttpRequest returns NotModified
6796 httpNotModified: function( xhr, url ) {
6797 /// <summary>
6798 /// This method is internal.
6799 /// </summary>
6800 /// <private />
6802 var lastModified = xhr.getResponseHeader("Last-Modified"),
6803 etag = xhr.getResponseHeader("Etag");
6805 if ( lastModified ) {
6806 jQuery.lastModified[url] = lastModified;
6809 if ( etag ) {
6810 jQuery.etag[url] = etag;
6813 // Opera returns 0 when status is 304
6814 return xhr.status === 304 || xhr.status === 0;
6817 httpData: function( xhr, type, s ) {
6818 /// <summary>
6819 /// This method is internal.
6820 /// </summary>
6821 /// <private />
6823 var ct = xhr.getResponseHeader("content-type") || "",
6824 xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
6825 data = xml ? xhr.responseXML : xhr.responseText;
6827 if ( xml && data.documentElement.nodeName === "parsererror" ) {
6828 jQuery.error( "parsererror" );
6831 // Allow a pre-filtering function to sanitize the response
6832 // s is checked to keep backwards compatibility
6833 if ( s && s.dataFilter ) {
6834 data = s.dataFilter( data, type );
6837 // The filter can actually parse the response
6838 if ( typeof data === "string" ) {
6839 // Get the JavaScript object, if JSON is used.
6840 if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
6841 data = jQuery.parseJSON( data );
6843 // If the type is "script", eval it in global context
6844 } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
6845 jQuery.globalEval( data );
6849 return data;
6852 // Serialize an array of form elements or a set of
6853 // key/values into a query string
6854 param: function( a, traditional ) {
6855 /// <summary>
6856 /// Create a serialized representation of an array or object, suitable for use in a URL
6857 /// query string or Ajax request.
6858 /// </summary>
6859 /// <param name="a" type="Object">
6860 /// An array or object to serialize.
6861 /// </param>
6862 /// <param name="traditional" type="Boolean">
6863 /// A Boolean indicating whether to perform a traditional "shallow" serialization.
6864 /// </param>
6865 /// <returns type="String" />
6867 var s = [];
6869 // Set traditional to true for jQuery <= 1.3.2 behavior.
6870 if ( traditional === undefined ) {
6871 traditional = jQuery.ajaxSettings.traditional;
6874 // If an array was passed in, assume that it is an array of form elements.
6875 if ( jQuery.isArray(a) || a.jquery ) {
6876 // Serialize the form elements
6877 jQuery.each( a, function() {
6878 add( this.name, this.value );
6881 } else {
6882 // If traditional, encode the "old" way (the way 1.3.2 or older
6883 // did it), otherwise encode params recursively.
6884 for ( var prefix in a ) {
6885 buildParams( prefix, a[prefix] );
6889 // Return the resulting serialization
6890 return s.join("&").replace(r20, "+");
6892 function buildParams( prefix, obj ) {
6893 if ( jQuery.isArray(obj) ) {
6894 // Serialize array item.
6895 jQuery.each( obj, function( i, v ) {
6896 if ( traditional ) {
6897 // Treat each array item as a scalar.
6898 add( prefix, v );
6899 } else {
6900 // If array item is non-scalar (array or object), encode its
6901 // numeric index to resolve deserialization ambiguity issues.
6902 // Note that rack (as of 1.0.0) can't currently deserialize
6903 // nested arrays properly, and attempting to do so may cause
6904 // a server error. Possible fixes are to modify rack's
6905 // deserialization algorithm or to provide an option or flag
6906 // to force array serialization to be shallow.
6907 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
6911 } else if ( !traditional && obj != null && typeof obj === "object" ) {
6912 // Serialize object item.
6913 jQuery.each( obj, function( k, v ) {
6914 buildParams( prefix + "[" + k + "]", v );
6917 } else {
6918 // Serialize scalar item.
6919 add( prefix, obj );
6923 function add( key, value ) {
6924 // If value is a function, invoke it and return its value
6925 value = jQuery.isFunction(value) ? value() : value;
6926 s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
6930 var elemdisplay = {},
6931 rfxtypes = /toggle|show|hide/,
6932 rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
6933 timerId,
6934 fxAttrs = [
6935 // height animations
6936 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
6937 // width animations
6938 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
6939 // opacity animations
6940 [ "opacity" ]
6943 jQuery.fn.extend({
6944 show: function( speed, callback ) {
6945 /// <summary>
6946 /// Show all matched elements using a graceful animation and firing an optional callback after completion.
6947 /// </summary>
6948 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
6949 /// the number of milliseconds to run the animation</param>
6950 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
6951 /// <returns type="jQuery" />
6953 if ( speed || speed === 0) {
6954 return this.animate( genFx("show", 3), speed, callback);
6956 } else {
6957 for ( var i = 0, l = this.length; i < l; i++ ) {
6958 var old = jQuery.data(this[i], "olddisplay");
6960 this[i].style.display = old || "";
6962 if ( jQuery.css(this[i], "display") === "none" ) {
6963 var nodeName = this[i].nodeName, display;
6965 if ( elemdisplay[ nodeName ] ) {
6966 display = elemdisplay[ nodeName ];
6968 } else {
6969 var elem = jQuery("<" + nodeName + " />").appendTo("body");
6971 display = elem.css("display");
6973 if ( display === "none" ) {
6974 display = "block";
6977 elem.remove();
6979 elemdisplay[ nodeName ] = display;
6982 jQuery.data(this[i], "olddisplay", display);
6986 // Set the display of the elements in a second loop
6987 // to avoid the constant reflow
6988 for ( var j = 0, k = this.length; j < k; j++ ) {
6989 this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
6992 return this;
6996 hide: function( speed, callback ) {
6997 /// <summary>
6998 /// Hides all matched elements using a graceful animation and firing an optional callback after completion.
6999 /// </summary>
7000 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7001 /// the number of milliseconds to run the animation</param>
7002 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7003 /// <returns type="jQuery" />
7005 if ( speed || speed === 0 ) {
7006 return this.animate( genFx("hide", 3), speed, callback);
7008 } else {
7009 for ( var i = 0, l = this.length; i < l; i++ ) {
7010 var old = jQuery.data(this[i], "olddisplay");
7011 if ( !old && old !== "none" ) {
7012 jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
7016 // Set the display of the elements in a second loop
7017 // to avoid the constant reflow
7018 for ( var j = 0, k = this.length; j < k; j++ ) {
7019 this[j].style.display = "none";
7022 return this;
7026 // Save the old toggle function
7027 _toggle: jQuery.fn.toggle,
7029 toggle: function( fn, fn2 ) {
7030 /// <summary>
7031 /// Toggles displaying each of the set of matched elements.
7032 /// </summary>
7033 /// <returns type="jQuery" />
7035 var bool = typeof fn === "boolean";
7037 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
7038 this._toggle.apply( this, arguments );
7040 } else if ( fn == null || bool ) {
7041 this.each(function() {
7042 var state = bool ? fn : jQuery(this).is(":hidden");
7043 jQuery(this)[ state ? "show" : "hide" ]();
7046 } else {
7047 this.animate(genFx("toggle", 3), fn, fn2);
7050 return this;
7053 fadeTo: function( speed, to, callback ) {
7054 /// <summary>
7055 /// Fades the opacity of all matched elements to a specified opacity.
7056 /// </summary>
7057 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7058 /// the number of milliseconds to run the animation</param>
7059 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7060 /// <returns type="jQuery" />
7062 return this.filter(":hidden").css("opacity", 0).show().end()
7063 .animate({opacity: to}, speed, callback);
7066 animate: function( prop, speed, easing, callback ) {
7067 /// <summary>
7068 /// A function for making custom animations.
7069 /// </summary>
7070 /// <param name="prop" type="Options">A set of style attributes that you wish to animate and to what end.</param>
7071 /// <param name="speed" optional="true" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7072 /// the number of milliseconds to run the animation</param>
7073 /// <param name="easing" optional="true" type="String">The name of the easing effect that you want to use. There are two built-in values, 'linear' and 'swing'.</param>
7074 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7075 /// <returns type="jQuery" />
7077 var optall = jQuery.speed(speed, easing, callback);
7079 if ( jQuery.isEmptyObject( prop ) ) {
7080 return this.each( optall.complete );
7083 return this[ optall.queue === false ? "each" : "queue" ](function() {
7084 var opt = jQuery.extend({}, optall), p,
7085 hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
7086 self = this;
7088 for ( p in prop ) {
7089 var name = p.replace(rdashAlpha, fcamelCase);
7091 if ( p !== name ) {
7092 prop[ name ] = prop[ p ];
7093 delete prop[ p ];
7094 p = name;
7097 if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
7098 return opt.complete.call(this);
7101 if ( ( p === "height" || p === "width" ) && this.style ) {
7102 // Store display property
7103 opt.display = jQuery.css(this, "display");
7105 // Make sure that nothing sneaks out
7106 opt.overflow = this.style.overflow;
7109 if ( jQuery.isArray( prop[p] ) ) {
7110 // Create (if needed) and add to specialEasing
7111 (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
7112 prop[p] = prop[p][0];
7116 if ( opt.overflow != null ) {
7117 this.style.overflow = "hidden";
7120 opt.curAnim = jQuery.extend({}, prop);
7122 jQuery.each( prop, function( name, val ) {
7123 var e = new jQuery.fx( self, opt, name );
7125 if ( rfxtypes.test(val) ) {
7126 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
7128 } else {
7129 var parts = rfxnum.exec(val),
7130 start = e.cur(true) || 0;
7132 if ( parts ) {
7133 var end = parseFloat( parts[2] ),
7134 unit = parts[3] || "px";
7136 // We need to compute starting value
7137 if ( unit !== "px" ) {
7138 self.style[ name ] = (end || 1) + unit;
7139 start = ((end || 1) / e.cur(true)) * start;
7140 self.style[ name ] = start + unit;
7143 // If a +=/-= token was provided, we're doing a relative animation
7144 if ( parts[1] ) {
7145 end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
7148 e.custom( start, end, unit );
7150 } else {
7151 e.custom( start, val, "" );
7156 // For JS strict compliance
7157 return true;
7161 stop: function( clearQueue, gotoEnd ) {
7162 /// <summary>
7163 /// Stops all currently animations on the specified elements.
7164 /// </summary>
7165 /// <param name="clearQueue" optional="true" type="Boolean">True to clear animations that are queued to run.</param>
7166 /// <param name="gotoEnd" optional="true" type="Boolean">True to move the element value to the end of its animation target.</param>
7167 /// <returns type="jQuery" />
7169 var timers = jQuery.timers;
7171 if ( clearQueue ) {
7172 this.queue([]);
7175 this.each(function() {
7176 // go in reverse order so anything added to the queue during the loop is ignored
7177 for ( var i = timers.length - 1; i >= 0; i-- ) {
7178 if ( timers[i].elem === this ) {
7179 if (gotoEnd) {
7180 // force the next step to be the last
7181 timers[i](true);
7184 timers.splice(i, 1);
7189 // start the next in the queue if the last step wasn't forced
7190 if ( !gotoEnd ) {
7191 this.dequeue();
7194 return this;
7199 // Generate shortcuts for custom animations
7200 // jQuery.each({
7201 // slideDown: genFx("show", 1),
7202 // slideUp: genFx("hide", 1),
7203 // slideToggle: genFx("toggle", 1),
7204 // fadeIn: { opacity: "show" },
7205 // fadeOut: { opacity: "hide" }
7206 // }, function( name, props ) {
7207 // jQuery.fn[ name ] = function( speed, callback ) {
7208 // return this.animate( props, speed, callback );
7209 // };
7210 // });
7212 jQuery.fn[ "slideDown" ] = function( speed, callback ) {
7213 /// <summary>
7214 /// Reveal all matched elements by adjusting their height.
7215 /// </summary>
7216 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7217 /// the number of milliseconds to run the animation</param>
7218 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7219 /// <returns type="jQuery" />
7221 return this.animate( genFx("show", 1), speed, callback );
7224 jQuery.fn[ "slideUp" ] = function( speed, callback ) {
7225 /// <summary>
7226 /// Hiding all matched elements by adjusting their height.
7227 /// </summary>
7228 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7229 /// the number of milliseconds to run the animation</param>
7230 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7231 /// <returns type="jQuery" />
7233 return this.animate( genFx("hide", 1), speed, callback );
7236 jQuery.fn[ "slideToggle" ] = function( speed, callback ) {
7237 /// <summary>
7238 /// Toggles the visibility of all matched elements by adjusting their height.
7239 /// </summary>
7240 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7241 /// the number of milliseconds to run the animation</param>
7242 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7243 /// <returns type="jQuery" />
7245 return this.animate( genFx("toggle", 1), speed, callback );
7248 jQuery.fn[ "fadeIn" ] = function( speed, callback ) {
7249 /// <summary>
7250 /// Fades in all matched elements by adjusting their opacity.
7251 /// </summary>
7252 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7253 /// the number of milliseconds to run the animation</param>
7254 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7255 /// <returns type="jQuery" />
7257 return this.animate( { opacity: "show" }, speed, callback );
7260 jQuery.fn[ "fadeOut" ] = function( speed, callback ) {
7261 /// <summary>
7262 /// Fades the opacity of all matched elements to a specified opacity.
7263 /// </summary>
7264 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
7265 /// the number of milliseconds to run the animation</param>
7266 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
7267 /// <returns type="jQuery" />
7269 return this.animate( { opacity: "hide" }, speed, callback );
7272 jQuery.extend({
7273 speed: function( speed, easing, fn ) {
7274 /// <summary>
7275 /// This member is internal.
7276 /// </summary>
7277 /// <private />
7279 var opt = speed && typeof speed === "object" ? speed : {
7280 complete: fn || !fn && easing ||
7281 jQuery.isFunction( speed ) && speed,
7282 duration: speed,
7283 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
7286 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
7287 jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
7289 // Queueing
7290 opt.old = opt.complete;
7291 opt.complete = function() {
7292 if ( opt.queue !== false ) {
7293 jQuery(this).dequeue();
7295 if ( jQuery.isFunction( opt.old ) ) {
7296 opt.old.call( this );
7300 return opt;
7303 easing: {
7304 linear: function( p, n, firstNum, diff ) {
7305 /// <summary>
7306 /// This member is internal.
7307 /// </summary>
7308 /// <private />
7310 return firstNum + diff * p;
7312 swing: function( p, n, firstNum, diff ) {
7313 /// <summary>
7314 /// This member is internal.
7315 /// </summary>
7316 /// <private />
7318 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
7322 timers: [],
7324 fx: function( elem, options, prop ) {
7325 /// <summary>
7326 /// This member is internal.
7327 /// </summary>
7328 /// <private />
7330 this.options = options;
7331 this.elem = elem;
7332 this.prop = prop;
7334 if ( !options.orig ) {
7335 options.orig = {};
7341 jQuery.fx.prototype = {
7342 // Simple function for setting a style value
7343 update: function() {
7344 /// <summary>
7345 /// This member is internal.
7346 /// </summary>
7347 /// <private />
7349 if ( this.options.step ) {
7350 this.options.step.call( this.elem, this.now, this );
7353 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
7355 // Set display property to block for height/width animations
7356 if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
7357 this.elem.style.display = "block";
7361 // Get the current size
7362 cur: function( force ) {
7363 /// <summary>
7364 /// This member is internal.
7365 /// </summary>
7366 /// <private />
7368 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
7369 return this.elem[ this.prop ];
7372 var r = parseFloat(jQuery.css(this.elem, this.prop, force));
7373 return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
7376 // Start an animation from one number to another
7377 custom: function( from, to, unit ) {
7378 this.startTime = now();
7379 this.start = from;
7380 this.end = to;
7381 this.unit = unit || this.unit || "px";
7382 this.now = this.start;
7383 this.pos = this.state = 0;
7385 var self = this;
7386 function t( gotoEnd ) {
7387 return self.step(gotoEnd);
7390 t.elem = this.elem;
7392 if ( t() && jQuery.timers.push(t) && !timerId ) {
7393 timerId = setInterval(jQuery.fx.tick, 13);
7397 // Simple 'show' function
7398 show: function() {
7399 /// <summary>
7400 /// Displays each of the set of matched elements if they are hidden.
7401 /// </summary>
7403 // Remember where we started, so that we can go back to it later
7404 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
7405 this.options.show = true;
7407 // Begin the animation
7408 // Make sure that we start at a small width/height to avoid any
7409 // flash of content
7410 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
7412 // Start by showing the element
7413 jQuery( this.elem ).show();
7416 // Simple 'hide' function
7417 hide: function() {
7418 /// <summary>
7419 /// Hides each of the set of matched elements if they are shown.
7420 /// </summary>
7422 // Remember where we started, so that we can go back to it later
7423 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
7424 this.options.hide = true;
7426 // Begin the animation
7427 this.custom(this.cur(), 0);
7430 // Each step of an animation
7431 step: function( gotoEnd ) {
7432 /// <summary>
7433 /// This method is internal.
7434 /// </summary>
7435 /// <private />
7437 var t = now(), done = true;
7439 if ( gotoEnd || t >= this.options.duration + this.startTime ) {
7440 this.now = this.end;
7441 this.pos = this.state = 1;
7442 this.update();
7444 this.options.curAnim[ this.prop ] = true;
7446 for ( var i in this.options.curAnim ) {
7447 if ( this.options.curAnim[i] !== true ) {
7448 done = false;
7452 if ( done ) {
7453 if ( this.options.display != null ) {
7454 // Reset the overflow
7455 this.elem.style.overflow = this.options.overflow;
7457 // Reset the display
7458 var old = jQuery.data(this.elem, "olddisplay");
7459 this.elem.style.display = old ? old : this.options.display;
7461 if ( jQuery.css(this.elem, "display") === "none" ) {
7462 this.elem.style.display = "block";
7466 // Hide the element if the "hide" operation was done
7467 if ( this.options.hide ) {
7468 jQuery(this.elem).hide();
7471 // Reset the properties, if the item has been hidden or shown
7472 if ( this.options.hide || this.options.show ) {
7473 for ( var p in this.options.curAnim ) {
7474 jQuery.style(this.elem, p, this.options.orig[p]);
7478 // Execute the complete function
7479 this.options.complete.call( this.elem );
7482 return false;
7484 } else {
7485 var n = t - this.startTime;
7486 this.state = n / this.options.duration;
7488 // Perform the easing function, defaults to swing
7489 var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
7490 var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
7491 this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
7492 this.now = this.start + ((this.end - this.start) * this.pos);
7494 // Perform the next step of the animation
7495 this.update();
7498 return true;
7502 jQuery.extend( jQuery.fx, {
7503 tick: function() {
7504 var timers = jQuery.timers;
7506 for ( var i = 0; i < timers.length; i++ ) {
7507 if ( !timers[i]() ) {
7508 timers.splice(i--, 1);
7512 if ( !timers.length ) {
7513 jQuery.fx.stop();
7517 stop: function() {
7518 clearInterval( timerId );
7519 timerId = null;
7522 speeds: {
7523 slow: 600,
7524 fast: 200,
7525 // Default speed
7526 _default: 400
7529 step: {
7530 opacity: function( fx ) {
7531 jQuery.style(fx.elem, "opacity", fx.now);
7534 _default: function( fx ) {
7535 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
7536 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
7537 } else {
7538 fx.elem[ fx.prop ] = fx.now;
7544 if ( jQuery.expr && jQuery.expr.filters ) {
7545 jQuery.expr.filters.animated = function( elem ) {
7546 return jQuery.grep(jQuery.timers, function( fn ) {
7547 return elem === fn.elem;
7548 }).length;
7552 function genFx( type, num ) {
7553 var obj = {};
7555 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
7556 obj[ this ] = type;
7559 return obj;
7561 if ( "getBoundingClientRect" in document.documentElement ) {
7562 jQuery.fn.offset = function( options ) {
7563 /// <summary>
7564 /// Set the current coordinates of every element in the set of matched elements,
7565 /// relative to the document.
7566 /// </summary>
7567 /// <param name="options" type="Object">
7568 /// An object containing the properties top and left, which are integers indicating the
7569 /// new top and left coordinates for the elements.
7570 /// </param>
7571 /// <returns type="jQuery" />
7573 var elem = this[0];
7575 if ( options ) {
7576 return this.each(function( i ) {
7577 jQuery.offset.setOffset( this, options, i );
7581 if ( !elem || !elem.ownerDocument ) {
7582 return null;
7585 if ( elem === elem.ownerDocument.body ) {
7586 return jQuery.offset.bodyOffset( elem );
7589 var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
7590 clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
7591 top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
7592 left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
7594 return { top: top, left: left };
7597 } else {
7598 jQuery.fn.offset = function( options ) {
7599 /// <summary>
7600 /// Set the current coordinates of every element in the set of matched elements,
7601 /// relative to the document.
7602 /// </summary>
7603 /// <param name="options" type="Object">
7604 /// An object containing the properties top and left, which are integers indicating the
7605 /// new top and left coordinates for the elements.
7606 /// </param>
7607 /// <returns type="jQuery" />
7609 var elem = this[0];
7611 if ( options ) {
7612 return this.each(function( i ) {
7613 jQuery.offset.setOffset( this, options, i );
7617 if ( !elem || !elem.ownerDocument ) {
7618 return null;
7621 if ( elem === elem.ownerDocument.body ) {
7622 return jQuery.offset.bodyOffset( elem );
7625 jQuery.offset.initialize();
7627 var offsetParent = elem.offsetParent, prevOffsetParent = elem,
7628 doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
7629 body = doc.body, defaultView = doc.defaultView,
7630 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
7631 top = elem.offsetTop, left = elem.offsetLeft;
7633 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
7634 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
7635 break;
7638 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
7639 top -= elem.scrollTop;
7640 left -= elem.scrollLeft;
7642 if ( elem === offsetParent ) {
7643 top += elem.offsetTop;
7644 left += elem.offsetLeft;
7646 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
7647 top += parseFloat( computedStyle.borderTopWidth ) || 0;
7648 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
7651 prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
7654 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
7655 top += parseFloat( computedStyle.borderTopWidth ) || 0;
7656 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
7659 prevComputedStyle = computedStyle;
7662 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
7663 top += body.offsetTop;
7664 left += body.offsetLeft;
7667 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
7668 top += Math.max( docElem.scrollTop, body.scrollTop );
7669 left += Math.max( docElem.scrollLeft, body.scrollLeft );
7672 return { top: top, left: left };
7676 jQuery.offset = {
7677 initialize: function() {
7678 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
7679 html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
7681 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
7683 container.innerHTML = html;
7684 body.insertBefore( container, body.firstChild );
7685 innerDiv = container.firstChild;
7686 checkDiv = innerDiv.firstChild;
7687 td = innerDiv.nextSibling.firstChild.firstChild;
7689 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
7690 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
7692 checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
7693 // safari subtracts parent border width here which is 5px
7694 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
7695 checkDiv.style.position = checkDiv.style.top = "";
7697 innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
7698 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
7700 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
7702 body.removeChild( container );
7703 body = container = innerDiv = checkDiv = table = td = null;
7704 jQuery.offset.initialize = jQuery.noop;
7707 bodyOffset: function( body ) {
7708 var top = body.offsetTop, left = body.offsetLeft;
7710 jQuery.offset.initialize();
7712 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
7713 top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
7714 left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
7717 return { top: top, left: left };
7720 setOffset: function( elem, options, i ) {
7721 // set position first, in-case top/left are set even on static elem
7722 if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
7723 elem.style.position = "relative";
7725 var curElem = jQuery( elem ),
7726 curOffset = curElem.offset(),
7727 curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
7728 curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
7730 if ( jQuery.isFunction( options ) ) {
7731 options = options.call( elem, i, curOffset );
7734 var props = {
7735 top: (options.top - curOffset.top) + curTop,
7736 left: (options.left - curOffset.left) + curLeft
7739 if ( "using" in options ) {
7740 options.using.call( elem, props );
7741 } else {
7742 curElem.css( props );
7748 jQuery.fn.extend({
7749 position: function() {
7750 /// <summary>
7751 /// Gets the top and left positions of an element relative to its offset parent.
7752 /// </summary>
7753 /// <returns type="Object">An object with two integer properties, 'top' and 'left'.</returns>
7755 if ( !this[0] ) {
7756 return null;
7759 var elem = this[0],
7761 // Get *real* offsetParent
7762 offsetParent = this.offsetParent(),
7764 // Get correct offsets
7765 offset = this.offset(),
7766 parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
7768 // Subtract element margins
7769 // note: when an element has margin: auto the offsetLeft and marginLeft
7770 // are the same in Safari causing offset.left to incorrectly be 0
7771 offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
7772 offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
7774 // Add offsetParent borders
7775 parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
7776 parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
7778 // Subtract the two offsets
7779 return {
7780 top: offset.top - parentOffset.top,
7781 left: offset.left - parentOffset.left
7785 offsetParent: function() {
7786 /// <summary>
7787 /// This method is internal.
7788 /// </summary>
7789 /// <private />
7791 return this.map(function() {
7792 var offsetParent = this.offsetParent || document.body;
7793 while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
7794 offsetParent = offsetParent.offsetParent;
7796 return offsetParent;
7802 // Create scrollLeft and scrollTop methods
7803 jQuery.each( ["Left", "Top"], function( i, name ) {
7804 var method = "scroll" + name;
7806 jQuery.fn[ method ] = function(val) {
7807 /// <summary>
7808 /// Gets and optionally sets the scroll left offset of the first matched element.
7809 /// </summary>
7810 /// <param name="val" type="Number" integer="true" optional="true">A positive number representing the desired scroll left offset.</param>
7811 /// <returns type="Number" integer="true">The scroll left offset of the first matched element.</returns>
7813 var elem = this[0], win;
7815 if ( !elem ) {
7816 return null;
7819 if ( val !== undefined ) {
7820 // Set the scroll offset
7821 return this.each(function() {
7822 win = getWindow( this );
7824 if ( win ) {
7825 win.scrollTo(
7826 !i ? val : jQuery(win).scrollLeft(),
7827 i ? val : jQuery(win).scrollTop()
7830 } else {
7831 this[ method ] = val;
7834 } else {
7835 win = getWindow( elem );
7837 // Return the scroll offset
7838 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
7839 jQuery.support.boxModel && win.document.documentElement[ method ] ||
7840 win.document.body[ method ] :
7841 elem[ method ];
7846 // Create scrollLeft and scrollTop methods
7847 jQuery.each( ["Left", "Top"], function( i, name ) {
7848 var method = "scroll" + name;
7850 jQuery.fn[ method ] = function(val) {
7851 /// <summary>
7852 /// Gets and optionally sets the scroll top offset of the first matched element.
7853 /// </summary>
7854 /// <param name="val" type="Number" integer="true" optional="true">A positive number representing the desired scroll top offset.</param>
7855 /// <returns type="Number" integer="true">The scroll top offset of the first matched element.</returns>
7857 var elem = this[0], win;
7859 if ( !elem ) {
7860 return null;
7863 if ( val !== undefined ) {
7864 // Set the scroll offset
7865 return this.each(function() {
7866 win = getWindow( this );
7868 if ( win ) {
7869 win.scrollTo(
7870 !i ? val : jQuery(win).scrollLeft(),
7871 i ? val : jQuery(win).scrollTop()
7874 } else {
7875 this[ method ] = val;
7878 } else {
7879 win = getWindow( elem );
7881 // Return the scroll offset
7882 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
7883 jQuery.support.boxModel && win.document.documentElement[ method ] ||
7884 win.document.body[ method ] :
7885 elem[ method ];
7890 function getWindow( elem ) {
7891 return ("scrollTo" in elem && elem.document) ?
7892 elem :
7893 elem.nodeType === 9 ?
7894 elem.defaultView || elem.parentWindow :
7895 false;
7898 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
7899 jQuery.each([ "Height" ], function( i, name ) {
7901 var type = name.toLowerCase();
7903 // innerHeight and innerWidth
7904 jQuery.fn["inner" + name] = function() {
7905 /// <summary>
7906 /// Gets the inner height of the first matched element, excluding border but including padding.
7907 /// </summary>
7908 /// <returns type="Number" integer="true">The outer height of the first matched element.</returns>
7910 return this[0] ?
7911 jQuery.css( this[0], type, false, "padding" ) :
7912 null;
7915 // outerHeight and outerWidth
7916 jQuery.fn["outer" + name] = function( margin ) {
7917 /// <summary>
7918 /// Gets the outer height of the first matched element, including border and padding by default.
7919 /// </summary>
7920 /// <param name="margins" type="Map">A set of key/value pairs that specify the options for the method.</param>
7921 /// <returns type="Number" integer="true">The outer height of the first matched element.</returns>
7923 return this[0] ?
7924 jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
7925 null;
7928 jQuery.fn[ type ] = function( size ) {
7929 /// <summary>
7930 /// Set the CSS height of every matched element. If no explicit unit
7931 /// was specified (like 'em' or '%') then &quot;px&quot; is added to the width. If no parameter is specified, it gets
7932 /// the current computed pixel height of the first matched element.
7933 /// Part of CSS
7934 /// </summary>
7935 /// <returns type="jQuery" type="jQuery" />
7936 /// <param name="cssProperty" type="String">
7937 /// Set the CSS property to the specified value. Omit to get the value of the first matched element.
7938 /// </param>
7940 // Get window width or height
7941 var elem = this[0];
7942 if ( !elem ) {
7943 return size == null ? null : this;
7946 if ( jQuery.isFunction( size ) ) {
7947 return this.each(function( i ) {
7948 var self = jQuery( this );
7949 self[ type ]( size.call( this, i, self[ type ]() ) );
7953 return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
7954 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
7955 elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
7956 elem.document.body[ "client" + name ] :
7958 // Get document width or height
7959 (elem.nodeType === 9) ? // is it a document
7960 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
7961 Math.max(
7962 elem.documentElement["client" + name],
7963 elem.body["scroll" + name], elem.documentElement["scroll" + name],
7964 elem.body["offset" + name], elem.documentElement["offset" + name]
7967 // Get or set width or height on the element
7968 size === undefined ?
7969 // Get width or height on the element
7970 jQuery.css( elem, type ) :
7972 // Set the width or height on the element (default to pixels if value is unitless)
7973 this.css( type, typeof size === "string" ? size : size + "px" );
7978 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
7979 jQuery.each([ "Width" ], function( i, name ) {
7981 var type = name.toLowerCase();
7983 // innerHeight and innerWidth
7984 jQuery.fn["inner" + name] = function() {
7985 /// <summary>
7986 /// Gets the inner width of the first matched element, excluding border but including padding.
7987 /// </summary>
7988 /// <returns type="Number" integer="true">The outer width of the first matched element.</returns>
7990 return this[0] ?
7991 jQuery.css( this[0], type, false, "padding" ) :
7992 null;
7995 // outerHeight and outerWidth
7996 jQuery.fn["outer" + name] = function( margin ) {
7997 /// <summary>
7998 /// Gets the outer width of the first matched element, including border and padding by default.
7999 /// </summary>
8000 /// <param name="margin" type="Map">A set of key/value pairs that specify the options for the method.</param>
8001 /// <returns type="Number" integer="true">The outer width of the first matched element.</returns>
8003 return this[0] ?
8004 jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
8005 null;
8008 jQuery.fn[ type ] = function( size ) {
8009 /// <summary>
8010 /// Set the CSS width of every matched element. If no explicit unit
8011 /// was specified (like 'em' or '%') then &quot;px&quot; is added to the width. If no parameter is specified, it gets
8012 /// the current computed pixel width of the first matched element.
8013 /// Part of CSS
8014 /// </summary>
8015 /// <returns type="jQuery" type="jQuery" />
8016 /// <param name="cssProperty" type="String">
8017 /// Set the CSS property to the specified value. Omit to get the value of the first matched element.
8018 /// </param>
8020 // Get window width or height
8021 var elem = this[0];
8022 if ( !elem ) {
8023 return size == null ? null : this;
8026 if ( jQuery.isFunction( size ) ) {
8027 return this.each(function( i ) {
8028 var self = jQuery( this );
8029 self[ type ]( size.call( this, i, self[ type ]() ) );
8033 return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
8034 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
8035 elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
8036 elem.document.body[ "client" + name ] :
8038 // Get document width or height
8039 (elem.nodeType === 9) ? // is it a document
8040 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
8041 Math.max(
8042 elem.documentElement["client" + name],
8043 elem.body["scroll" + name], elem.documentElement["scroll" + name],
8044 elem.body["offset" + name], elem.documentElement["offset" + name]
8047 // Get or set width or height on the element
8048 size === undefined ?
8049 // Get width or height on the element
8050 jQuery.css( elem, type ) :
8052 // Set the width or height on the element (default to pixels if value is unitless)
8053 this.css( type, typeof size === "string" ? size : size + "px" );
8058 // Expose jQuery to the global object
8059 window.jQuery = window.$ = jQuery;
8061 })(window);